-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_problem.py
58 lines (44 loc) · 1.3 KB
/
gen_problem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import shutil
import sys
import gen_description
import gen_test_case
import problem_config
import run_solution
import verify_input
def PrepareGeneratedDirectory(problem_dir):
generated_dir = os.path.join(problem_dir, "generated")
if os.path.isdir(generated_dir):
shutil.rmtree(generated_dir)
os.makedirs(generated_dir)
return generated_dir
def GenerateDescription(problem_dir):
gen_description.GenerateDescription(problem_dir)
def GenerateTestCase(problem_dir):
gen_test_case.GenerateTestCase(problem_dir)
def VerifyInput(problem_dir):
verify_input.VerifyInput(problem_dir)
def RunSolutions(problem_dir):
run_solution.RunSolutions(problem_dir)
def CleanUp(problem_dir):
config = problem_config.get_problem_config(problem_dir)
if config.interactive:
os.remove("communicator")
else:
os.remove("scorer")
os.remove("solution")
runner_exec = os.path.join(problem_dir, "runner")
os.remove(runner_exec)
shutil.rmtree("tc")
def main():
if len(sys.argv) != 2:
raise RuntimeError("Usage: python gen_problem.py problem_dir")
problem_dir = sys.argv[1]
PrepareGeneratedDirectory(problem_dir)
GenerateDescription(problem_dir)
GenerateTestCase(problem_dir)
VerifyInput(problem_dir)
RunSolutions(problem_dir)
CleanUp(problem_dir)
if __name__ == "__main__":
main()