-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_readme.py
More file actions
83 lines (66 loc) · 2.07 KB
/
Copy pathcreate_readme.py
File metadata and controls
83 lines (66 loc) · 2.07 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from autokattis import OpenKattis
from dataclasses import dataclass
import os
env_keys={}
with open(".env", "r") as f:
lines=f.readlines()
for line in lines:
k,v=line.strip().split("=",1)
env_keys[k]=v
kt = OpenKattis(username="joshua-ganschow", password=env_keys['kattis_password'])
print("logged in successfully")
problems_solved = kt.problems()
problems_unsolved = kt.problems(show_tried=True, show_solved=False)
print(f"pulled {len(problems_solved)+len(problems_unsolved)} problems succesfully")
files = [f for f in os.listdir("sol") if os.path.isfile(os.path.join("sol", f))]
@dataclass
class problem:
name: str
pid: str
difficulty: float
diff_cat: str
solved: bool
problems = []
failed = []
seen=set()
for f in files:
pr=None
if f.split(".")[-1] not in ["py","cpp","c"]: continue
problem_id = f.split(".")[0].split("_")[0]
if problem_id in seen:
continue
seen.add(problem_id)
print(problem_id)
for prob in problems_solved:
if prob['id']==problem_id:
pr=problem(prob['name'], problem_id, prob['difficulty'], prob['category'], True)
break
else:
for prob in problems_unsolved:
if prob['id']==problem_id:
pr=problem(prob['name'], problem_id, prob['difficulty'], prob['category'], False)
if pr:
problems.append(pr)
else:
failed.append(problem_id)
print("parsed all files")
lines = []
lines.append("# open.kattis.com solutions")
lines.append("|Name|Id|Difficulty|Solved?|")
lines.append("|----|--|----------|-------|")
num_solved = 0
num_unsolved = 0
diff_total = 0
for p in sorted(problems, key=lambda x: x.name):
if p.solved:
num_solved+=1
diff_total += p.difficulty
else: num_unsolved+=1
lines.append(f"|[{p.name}](https://open.kattis.com/problems/{p.pid})|{p.pid}|{p.diff_cat}({p.difficulty})|{p.solved}|")
lines.extend(["\n","---"])
lines.append(f"Total solved: {num_solved}\n")
lines.append(f"Total unsolved: {num_unsolved}\n")
lines.append(f"Average difficulty solved: {diff_total/len(problems_solved)}\n")
print("created readme")
with open("out", "w") as out:
out.write("\n".join(lines))