forked from microsoft/PythonProgrammingPuzzles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter_outputs.py
More file actions
34 lines (27 loc) · 758 Bytes
/
Copy pathfilter_outputs.py
File metadata and controls
34 lines (27 loc) · 758 Bytes
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
import json
import sys
import os
inp_file = sys.argv[1]
if len(sys.argv) > 2:
shift = int(sys.argv[2])
else:
shift = 0
out_file = os.path.splitext(inp_file)[0]
with open(inp_file, 'r') as f:
data = json.load(f)
thresholds = [100, 1000, 10000, 100000, 1000000]
for t in thresholds:
t = t
out = []
suc = 0
for p in data:
#if not p["name"].startswith("Study"):
# continue
if p["sols"][-1] != "" and p["sol_tries"][-1] + shift <= t:
out.append(p)
suc += 1
else:
out.append(dict(name=p["name"], sat=p["sat"], sols=[]))
print(f"t={t}: solutions: {suc}/ {len(out)}")
with open(out_file + f"_{t}.json", "w") as fw:
json.dump(out, fw, indent=4)