-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
34 lines (29 loc) · 1.16 KB
/
generator.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
import json
import re
r = re.compile(r"[^a-zA-Z0-9-]")
challengesj = open("challenges.json")
challenges = json.load(challengesj)
with open("README.md", "a") as f:
f.write("\n---\n\n")
for cat in challenges:
f.write(f"[{cat.upper()}](#{cat})\n\n")
for challenge in challenges[cat]:
id = r.sub("", challenge["name"].replace(" ", "-")).lower()
f.write(f"- [{challenge['name']}](#{id})\n")
f.write("\n")
f.write("---\n\n")
for cat in challenges:
f.write(f"## {cat.upper()}\n\n")
for challenge in challenges[cat]:
f.write(f"### {challenge['name']}\n\n")
f.write(f"Points: {challenge['points']}\n")
f.write(f"Solves: {challenge['solves']}\n")
f.write(f"Author: {challenge['author']}\n")
f.write("\n")
f.write(f"Flag: {challenge['flag']}\n\n")
f.write("#### Description\n\n")
description = "> " + challenge["description"].replace("\n", "\n> ")
f.write(f"{description}\n\n")
for i, hint in enumerate(challenge["hints"]):
f.write(f"Hint {i+1}: {hint}\n\n")
challengesj.close()