-
Notifications
You must be signed in to change notification settings - Fork 27
/
solved.py
41 lines (24 loc) · 792 Bytes
/
solved.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
33
34
35
36
37
38
39
40
import os
def count_solved(path):
solved = 0
for entry in os.listdir(path):
if entry.startswith('.'):
continue
fullpath = os.path.join(path, entry)
if os.path.isdir(fullpath):
if any(file.endswith('.py') for file in os.listdir(fullpath)):
solved += 1
solved += count_solved(fullpath)
return solved
solved = count_solved('.')
txt = 'challenges solved'
print(solved, txt)
with open("README.md", "r") as readme:
lines = []
for line in readme:
if txt in line:
lines.append('### **' + str(solved) + '** ' + txt + ':\n')
else:
lines.append(line)
with open("README.md", "w") as readme:
readme.writelines(lines)