import os, shutil
from random import *
import random
seed("omg")

class ScarTestGen:
	def __init__(self):
		self.test_number = 0
	
	def random_string(self, ln, maxalphabet):
		a = ""
		for i in range(0, ln):
			a += (chr(random.randint(0, maxalphabet - 1) + ord('a')))
		return a
	 
	def make_strings(self, number, minln, maxln, minal, maxal):
		a = []
		for i in range(0, number):
			a.append(self.random_string(random.randint(minln, maxln), random.randint(minal, maxal)))
		return a

	def print_test(self, a):
		self.test_number += 1
		test_name = "../tests/" + "{0:0=2d}".format(self.test_number)
		test_file = open(test_name, "w")
		print(len(a), file=test_file)
		print('\n'.join(str(element) for element in a), file=test_file)
		test_file.close()
	
	def gen(self):
		a = []
		a.append("aaa")
		a.append("aa")
		self.print_test(a)

		a = []
		a.append("ab")
		a.append("abc")
		self.print_test(a)

		a = []
		a.append("qwerty")
		a.append("qwerty")
		a.append("ytrewq")
		self.print_test(a)
		MAXN = 10
		MAXLEN = 10

		for i in range(0, 5):
			a = self.make_strings(random.randint(5, 10), 3, 5, 1, 3)
			self.print_test(a)

		for i in range(0, 5):
			a = self.make_strings(random.randint(10, 10), 3, 5, 1, 3)
			a.sort()
			self.print_test(a)

		for i in range(0, 5):
			a = self.make_strings(random.randint(5, 10), 3, 5, 5, 7)
			a.sort()
			self.print_test(a)

		for i in range(0, 5):
			a = self.make_strings(random.randint(5, MAXN), 5, 10, 7, 10)
			self.print_test(a)

		for i in range(0, 5):
			a = self.make_strings(random.randint(10, MAXN), 5, 10, 10, 15)
			a.sort()
			self.print_test(a)

		for i in range(0, 5):
			a = self.make_strings(random.randint(int(MAXN/2), MAXN), int(MAXLEN/2), MAXLEN, 15, 25)
			a.sort()
			self.print_test(a)

		for i in range(0, 5):
			a = self.make_strings(random.randint(MAXN, MAXN), MAXLEN, MAXLEN, 25, 25)
			a.sort()
			self.print_test(a)
		
		a = []
		for i in range(0, MAXN):
			b = ""
			for j in range(0, MAXLEN):
				b += chr(ord('a') + (int)(i/4))
			a.append(b)
		self.print_test(a)	

		a = []
		for i in range(0, MAXN):
			b = ""
			r = (int)(i / 10)				
			for j in range(0, MAXLEN):
				b += chr(ord('a') + (int)(j + r))
			a.append(b)
		self.print_test(a)	

		a = []
		for i in range(0,MAXN):
			b = ""
			for j in range(0, MAXLEN):
				b += chr(ord('a') + (int)(j))
			a.append(b)
		self.print_test(a)	

		
		a = []
		for i in range(0, MAXN):
			b = ""
			for j in range(0, MAXLEN):
				b += chr(ord('a') + (int)(j + (int)(i/7)))
			a.append(b)
		self.print_test(a)
		
		a = []
		for i in range(0, MAXN):
			b = ""
			for j in range(0, MAXLEN):
				b += chr(ord('a') + i + random.randint(0, 10))
			a.append(b)
		self.print_test(a)
			




if os.path.exists('../tests'):
	shutil.rmtree('../tests', ignore_errors=False, onerror=None)
try:
	os.makedirs('../tests')
except OSError:
	pass

writer = ScarTestGen()
writer.gen()
