Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9b19c39

Browse files
committed
add missing.py
1 parent 5ffedba commit 9b19c39

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

missing.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
script that determines which problems I have solved but only in a different language than the given language
3+
"""
4+
5+
import sys
6+
import os
7+
import re
8+
from collections import defaultdict
9+
10+
if len(sys.argv) == 1:
11+
sys.stderr.write('You must specify the language extension\n')
12+
sys.exit(1)
13+
else:
14+
lang = sys.argv[1]
15+
16+
pattern = re.compile(r'^(\d{4}-[a-z0-9\-]+)(\.[a-z]{2,4})$')
17+
18+
ignored_extensions = (
19+
'js', # because of JS-only problems
20+
'sh',
21+
'sql',
22+
'md' # not a programming language
23+
)
24+
25+
files = [
26+
file for file in os.listdir(os.getcwd())
27+
if re.fullmatch(pattern, file) and
28+
not any(file.endswith(x) for x in ignored_extensions)
29+
]
30+
31+
langs = defaultdict(set)
32+
33+
for file in files:
34+
match = re.fullmatch(pattern, file)
35+
if not match:
36+
sys.stderr.write(f'{file} did not match pattern\n')
37+
continue
38+
langs[match.group(2)[1:]].add(file[:match.end(1)])
39+
40+
from functools import reduce
41+
42+
sol = reduce(lambda x, y: x | y, (x for x in langs.values() if x != lang))
43+
44+
print(sol - langs[lang])

0 commit comments

Comments
 (0)