def main(): for i in xrange(25): problem_path = get_path('../../problems', i) with open(problem_path) as reader: config = json.load(reader) for seed in config['sourceSeeds']: dest_path = '../../cpp_input/problem_{0}_{1}.txt'.format(i, seed) with open(dest_path, 'w') as writer: writer.write(translate.translate_single(config, seed, phrases.known_phrases))
def run(exe_path, config, seed, phrases=None, timelimit=3600): if phrases is None: phrases = [] start_time = time.time() input_string = translate_single(config, seed, phrases, timelimit) proc = subprocess.Popen([exe_path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) command, stderr = proc.communicate(input_string) if aidebug_dir: with open(get_path(aidebug_dir, config['id']) + '.{}.txt'.format(seed), 'w') as writer: writer.write(stderr) if phrases: command = daisaku.optimize(command, phrases) elapsed_time = time.time() - start_time return create_single_output(config, seed, command, elapsed_time)