-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeREADME.py
More file actions
executable file
·61 lines (48 loc) · 1.23 KB
/
makeREADME.py
File metadata and controls
executable file
·61 lines (48 loc) · 1.23 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import re
import datetime
easy = 0
medium = 0
hard = 0
def main():
summarize()
logEntry()
copyTheWholeFile()
def copyTheWholeFile():
with open("db.md", 'r') as f, open("README.md", 'a') as o:
o.write("\n\n")
for line in f.readlines():
if(len(line) > 1 and line[0] == '#'):
continue
if(re.match('[1-9].', line)):
o.write('_' + line);
else:
o.write(line)
def summarize():
with open("db.md", 'r') as f, open("README.md", 'w') as o:
state = 'easy'
global easy
global medium
global hard
for line in f.readlines():
if (line.strip() == '**medium**'):
state = 'medium'
elif (line.strip() == '**hard**'):
state = 'hard'
else:
if(re.match('\d+\.', line)):
if(state == 'easy'):
easy += 1
elif(state == 'medium'):
medium +=1
elif (state == 'hard'):
hard += 1
total = easy + medium + hard
o.write("# leetcode\n")
o.write("**Total Problem Solved: {}**\n".format(total))
o.write("* easy: {}\n".format(easy))
o.write("* medium: {}\n".format(medium))
o.write("* hard: {}\n".format(hard))
def logEntry():
with open("db.md", 'a') as o:
o.write("\n* {}: {}-{}-{} | sum: {}".format(datetime.date.today(), easy, medium, hard, (easy + medium + hard)))
main()