import random as rd
import math

def write_inst(file_name, samples):
	with open(file_name, 'w') as file:
		n = len(samples)
		file.write(str(n) + '\n')
		for i in range(n):
			num = samples[i][1]
			string = '{} {}'.format(samples[i][0], num)
			for j in range(num):
				string += ' ' + str(samples[i][2][j])
			string += '\n'
			file.write(string)


def make_random(hash_length, hashs):
	half = int(hash_length/2.0)
	l = rd.randint(hash_length-half, hash_length+half)
	has = rd.choices(hashs, k=l)
	orient = 'H'
	if rd.random() > 0.5: orient = 'V'
	return (orient, l, has)



def main(size):
	samples = [0]*size
	hash_length = int(math.log2(size))
	hashs = range(int(math.log10(size))*hash_length)
	for i in range(size):
		samples[i] = make_random(hash_length, hashs)
	write_inst('synth'+str(size)+'.txt', samples)

main(20000)
