Skip to content

Commit aad668f

Browse files
committed
change title to Chinese
1 parent 979edb1 commit aad668f

File tree

383 files changed

+423
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+423
-382
lines changed

assets/scripts/generate.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,47 @@
66
import const
77
import utils
88

9+
def changeTitle():
10+
files = os.listdir(const.problem_path)
11+
df = pd.read_csv("problem-list.csv")
12+
for file in files:
13+
# 判断是否是文件夹
14+
if ".md" not in file:
15+
continue
16+
if "README" in file:
17+
continue
18+
19+
file_path = os.path.join(const.problem_path, Path(file))
20+
content = Path(file_path).read_text(encoding='utf-8')
21+
22+
delim = ''
23+
delim1 = "🟢"
24+
delim2 = "🟠"
25+
delim3 = "🔴"
26+
if delim1 in content:
27+
delim = delim1
28+
if delim2 in content:
29+
delim = delim2
30+
if delim3 in content:
31+
delim = delim3
32+
33+
before, after = content.split(delim)
34+
35+
df_indexs = df[df['fileName'] == Path(file).stem].index.tolist()
36+
37+
if not df_indexs:
38+
print('%s 没有出现在 problem-list.csv 中' % (Path(file).stem))
39+
continue
40+
41+
row= df_indexs[0]
42+
problem_id = df.loc[row, "frontedId"]
43+
problem_title = df.loc[row, "titleCN"]
44+
problem_slug = utils.getLink(problem_id, df.loc[row, "slug"])
45+
46+
newTitle = "# [{}. {}]({})\n\n".format(problem_id, problem_title, problem_slug)
47+
text = newTitle + delim + after
48+
Path(file_path).write_text(text, encoding='utf-8')
49+
950

1051
# 自动生成已完成题目总列表
1152

src/leetcode/problem/0001.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0002.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0003.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0004.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0005.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0006.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0007.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0008.md

Lines changed: 1 addition & 1 deletion

src/leetcode/problem/0009.md

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)