Skip to content

Commit 9d1c286

Browse files
committed
chore: add contest part
1 parent 5be6683 commit 9d1c286

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

main.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,40 @@
33
from collections import defaultdict
44

55

6+
def format_contest_md(content: str) -> str:
7+
content = content.replace('[English Version](/solution/CONTEST_README_EN.md)', '')
8+
content = content.replace('[中文文档](/solution/CONTEST_README.md)', '')
9+
# - [3069. Distribute Elements Into Two Arrays I](/solution/3000-3099/3069.Distribute%20Elements%20Into%20Two%20Arrays%20I/README_EN.md)
10+
# 将如上格式的链接替换为 /leetcode/lc/3069.md,即
11+
res = re.findall(r"\[(.*?)\]\((.*?)\)", content)
12+
for title, link in res:
13+
num = link.split("/")[-2].split('.')[0]
14+
content = content.replace(link, f"/leetcode/lc/{num}.md")
15+
return content
16+
17+
def format_contest_md_en(content: str) -> str:
18+
content = content.replace('[English Version](/solution/CONTEST_README_EN.md)', '')
19+
content = content.replace('[中文文档](/solution/CONTEST_README.md)', '')
20+
# - [3069. Distribute Elements Into Two Arrays I](/solution/3000-3099/3069.Distribute%20Elements%20Into%20Two%20Arrays%20I/README_EN.md)
21+
# 将如上格式的链接替换为 /leetcode/lc/3069.md,即
22+
res = re.findall(r"\[(.*?)\]\((.*?)\)", content)
23+
for title, link in res:
24+
num = link.split("/")[-2].split('.')[0]
25+
content = content.replace(link, f"/leetcode/en/lc/{num}.md")
26+
return content
27+
28+
with open("docs/contest.md", "r", encoding="utf-8") as f:
29+
contest = f.read()
30+
contest = format_contest_md(contest)
31+
with open("docs/contest.md", "w", encoding="utf-8") as f:
32+
f.write(contest)
33+
34+
with open("docs-en/contest.md", "r", encoding="utf-8") as f:
35+
contest_en = f.read()
36+
contest_en = format_contest_md_en(contest_en)
37+
with open("docs-en/contest.md", "w", encoding="utf-8") as f:
38+
f.write(contest_en)
39+
640
code_dict = {
741
"py": ("Python3", "python"),
842
"java": ("Java", "java"),
@@ -163,6 +197,7 @@ def get_paths(dirs: str, m: int):
163197
- 剑指 Offer(专项突破):\n{lcof2}
164198
- 程序员面试金典:\n{lcci}
165199
- 专项训练: tags.md
200+
- 竞赛专区: contest.md
166201
167202
"""
168203

@@ -177,6 +212,7 @@ def get_paths(dirs: str, m: int):
177212
- LeetCode:\n{lc}
178213
- Cracking the Coding Interview:\n{lcci}
179214
- Focused Training: tags.md
215+
- Contest: contest.md
180216
181217
"""
182218

0 commit comments

Comments
 (0)