import random
random.seed("spb-team-2015/sapsan")

class TestGen:
    def __init__(self):
        self.test_number = 0

    def generate_samples(self):
        self.print_test(10)
        
    def generate_min_tests(self):
        for i in range(1, 11):
            self.print_test(i)
                                                                    
    def generate_hand_tests(self):
        pass

    def generate_random_test(self, maxn):
        self.print_test(random.randint(1, maxn))

    def generate_max_tests(self, maxn):
        for i in range(maxn - 10, maxn + 1):
            self.print_test(i)

    def print_test(self, n):
        self.test_number += 1
        print('Generating test #%d' % self.test_number)

        test_name = "../tests/" + "{0:0=2d}".format(self.test_number)
        test_file = open(test_name, "w")
        print(n * 2, file=test_file)
        test_file.close()

    def generate_all_tests(self):
        self.generate_samples()
        self.generate_min_tests()
        self.generate_hand_tests()
        
        maxn = 10**9 // 2
        for i in range(10):
            self.generate_random_test(maxn)
        self.generate_max_tests(maxn)        

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

import time
start = time.time()
writer = TestGen()
writer.generate_all_tests()
finish = time.time()
print('All tests were generated. Elapsed time: ', finish - start)
