-
Notifications
You must be signed in to change notification settings - Fork 0
/
equivvy.py
executable file
·47 lines (41 loc) · 1.16 KB
/
equivvy.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
41
42
43
44
45
46
47
#!/usr/bin/python
import sys
import subprocess
import os
maxno = int(sys.argv[1])
classes = dict()
def exists(i):
if i in classes.keys():
True
for c in classes.values():
if i in c:
return True
return False
for i in range(1, maxno + 1):
print i
try:
fi = os.stat("problems/prob" + str(i))
except OSError:
continue
if exists(i):
continue
for j in range(i + 1, maxno + 1):
if not exists(j):
try:
fj = os.stat("problems/prob" + str(j))
except OSError:
continue
if fi.st_size <> fj.st_size:
continue
try:
out = subprocess.check_output(["diff", "problems/prob" + str(i),
"problems/prob" + str(j)],
stderr = subprocess.STDOUT)
except subprocess.CalledProcessError:
continue
if len(out) == 0:
if i in classes:
classes[i] = classes[i] + [j]
else:
classes[i] = [j]
print classes