3
3
from collections import defaultdict
4
4
5
5
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
+
6
40
code_dict = {
7
41
"py" : ("Python3" , "python" ),
8
42
"java" : ("Java" , "java" ),
@@ -163,6 +197,7 @@ def get_paths(dirs: str, m: int):
163
197
- 剑指 Offer(专项突破):\n { lcof2 }
164
198
- 程序员面试金典:\n { lcci }
165
199
- 专项训练: tags.md
200
+ - 竞赛专区: contest.md
166
201
167
202
"""
168
203
@@ -177,6 +212,7 @@ def get_paths(dirs: str, m: int):
177
212
- LeetCode:\n { lc }
178
213
- Cracking the Coding Interview:\n { lcci }
179
214
- Focused Training: tags.md
215
+ - Contest: contest.md
180
216
181
217
"""
182
218
0 commit comments