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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/python
import sys
from server.problems import load_problem
if len(sys.argv) < 5:
sys.stderr.write('usage: {} programming_language group problem language\n'.format(sys.argv[0]))
sys.exit(1)
language, group, problem, tail = sys.argv[1:]
mod = load_problem(language, group, problem, tail)
print('''\
<DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Problem</title>
<style>
h2 {
margin-top: 1em;
margin-bottom: 0.5em;
}
h3 {
margin-bottom: 0.3em;
margin-top: 0.2em;
}
p {
margin-bottom: 0.2em;
margin-top: 0;
}
section {
margin-bottom: 1.5em;
}
</style>
</head>
<body>''')
print('<h1>{}</h1>'.format(mod.name))
print('{}'.format(mod.description))
print('<section>')
print('<h2>Plan</h2>')
for n, plan in enumerate(mod.plan):
print('<section>')
print('<h3>Plan #{}</h3>'.format(n))
if isinstance(plan, list):
for i, p_part in enumerate(plan):
if isinstance(p_part, dict):
p_part = p_part['message']
print(p_part)
if i < len(plan)-1:
print('<hr />')
else:
print(plan)
print('</section>')
print('</section>')
print('<section>')
print('<h2>Hints</h2>')
for id, hint in sorted(mod.hint.items()):
print('<section>')
print('<h3>{}</h3>'.format(id))
if isinstance(hint, list):
for i, hint_part in enumerate(hint):
if isinstance(hint_part, dict):
hint_part = hint_part['message']
print(hint_part)
if i < len(hint)-1:
print('<hr />')
else:
print(hint)
print('</section>')
print('</section>')
print('''\
</body>
</html>''')
|