from random import *
from os import path, mkdir

seed("ololo")
test000 = 0

def printTest(s):
	global test000
	test000 += 1
	if not (path.exists('../tests')):
		mkdir('../tests')
	ouf = open("../tests/%02d" % test000, "w")
	print(s, file = ouf)
	ouf.close()

def gen_brackets(br_len):
	open = br_len // 2
	bal = 0
	res = ""
	while (open > 0):
		type = 0 if bal == 0 else randint(0, 1)
		if type == 0: #open brackets
			res += '('
			open -= 1
			bal += 1
		else:
			res += ')'
			bal -= 1
	while (bal > 0):
		res += ')'
		bal -= 1
	return res
	
def gen_random_string(br_len, sym_len):
	s = gen_brackets(br_len)
	alp = 'lokithorodin+*-/ 0123456789'
	for i in range(sym_len):
		t = randint(0, len(s))
		s = s[:t] + choice(alp) + s[t:]
	return s
	
printTest("x * (y + (z * (5 + 3)))")
printTest("1 * (0 + k + i) * (t - h + (0 * r))")	
printTest(gen_random_string(10,10))
printTest(gen_random_string(10000,10000))	
printTest(gen_random_string(100000,0))	
printTest(gen_random_string(0,100000))	
printTest(gen_random_string(50000,50000))	
printTest(gen_random_string(10000,100))	
printTest(gen_random_string(10000,1000))	
printTest(gen_random_string(10000,300))	
printTest(gen_random_string(10000,1))		