-
Notifications
You must be signed in to change notification settings - Fork 367
/
Copy pathscript.py
executable file
·32 lines (28 loc) · 1.12 KB
/
script.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
#!/usr/bin/env python3
import os
from os import listdir, getcwd
from os.path import isfile, join
current_dir = getcwd()
# Clean up
# current_files = os.listdir(current_dir)
# for item in current_files:
# if item.endswith(".md"):
# os.remove(os.path.join(current_dir, item))
tree_path = "https://github.com/varunu28/LeetCode-Java-Solutions/tree/master/"
levels = ["Easy", "Medium", "Hard"]
for level in levels:
if os.path.exists(current_dir + "/" + level + "/README.md"):
os.remove(current_dir + "/" + level + "/README.md")
onlyfiles = [f for f in listdir(current_dir + "/" + level)]
f= open(current_dir + "/" + level + "/README.md","w+")
f.write("# " + level + " LeetCode-Java-Solutions \n")
f.write("S.no | Coding Problem \n")
f.write("--- | --- \n")
count = 1
for file_name in onlyfiles:
only_name = file_name[:file_name.find('.')]
updated_file_name = file_name.replace(' ', '%20')
f.write(str(count) + "|" + '[{}]({})\n'.format(only_name, (tree_path + level + "/" + updated_file_name)))
count = count + 1
print(level + ": " + str(count))
f.close()