-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_main_page.py
More file actions
68 lines (51 loc) · 1.24 KB
/
create_main_page.py
File metadata and controls
68 lines (51 loc) · 1.24 KB
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
import os
from autokattis import Kattis
from dotenv import load_dotenv
import shutil
load_dotenv(".env")
desc = """
These are problems I have solved on [Kattis](https://open.kattis.com)
while preparing for competitive programming competitions.
"""
table = """
<table>
<thead>
<td>Name</td>
<td>Difficulty</td>
<td>Link</td>
</thead>
<tbody>
"""
tableFormat = """
<tr>
<td>{name}</td>
<td>{difficulty}</td>
<td>{link}</td>
</tr>
"""
tableEnd = """
</tbody>
</table>
"""
# Log in to kattis
kt = Kattis(os.environ.get("K_USER"), os.environ.get("K_PASS"))
with open("README.md", 'w') as obj:
obj.write("# King-McD Kattis Problems\n")
obj.write(desc)
kt.plot_problems(filepath="plot.png", show_partial=False)
obj.write("### Problem Difficulty\n")
obj.write("")
problems = kt.problems(show_partial=False)
obj.write(table)
problems.sort(key=lambda x: x["difficulty"])
hard = []
s = 0
for p in problems:
s += p["difficulty"]
if p["difficulty"] >= 5.5:
hard.append(p)
# p["name"] = p["name"].decode('utf-8')
obj.write(tableFormat.format(**p))
s /= len(problems)
print("TOTAL NUMBER OF HARD PROBLEMS:", len(hard))
print("AVERAGE PROBLEM DIFFICULTY:", s)