-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter.py
More file actions
65 lines (55 loc) · 1.58 KB
/
counter.py
File metadata and controls
65 lines (55 loc) · 1.58 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
61
62
63
64
65
import os
from termcolor import colored
global perLine
perLine = 20
def parse(filename):
ret = filename.split(".")[0]
ret = ret.split("-")[0]
ret = ret.split("_")[0]
if ret.isdigit():
return int(ret)
else:
raise Exception
def prettyprint(sList, pList):
green, red = 0, 0
li = []
for i in range(len(sList)):
if sList[i] in pList:
print(colored(str(sList[i]), 'green'), end="\t")
green += 1
li.append(sList[i])
else:
print(colored(str(sList[i]), 'red'), end="\t")
red += 1
if (i + 1) % perLine == 0:
print("")
print("")
return li
def solved(filename):
solvedList = []
f = open(filename, "r")
for line in f:
for e in line.split(" "):
solvedList.append(int(e))
solvedList.sort()
return solvedList
def getProbList(dir):
probList = set()
for root, dirs, files in os.walk(dir, topdown = True):
for name in files:
try:
probList.add(parse(name))
except Exception as e:
pass
probList = list(probList)
probList.sort()
return probList
# Pass the filename that contains solved problems
solvedList = solved("./solved")
# Pass the directory that contains the solution codes
probList = getProbList("./Codes")
li = prettyprint(solvedList, probList)
assert li == probList
print("Total No. of Problems: %d" % len(solvedList))
print("Existing No. of Problems: %d" % len(probList))
print("Needs to be updated: %d" % (len(solvedList) - len(probList)))