-
Notifications
You must be signed in to change notification settings - Fork 2
/
just_so.py
50 lines (35 loc) · 1.06 KB
/
just_so.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
48
49
50
import sys
import argparse
from multiprocessing import Pool
from tm.reason import (
cant_halt,
cant_blank,
cant_spin_out,
segment_cant_halt,
)
CYCLES = 2_000
CANT_REACH = cant_spin_out
def worker(prog: str) -> None:
if CANT_REACH(prog, CYCLES) is not None:
return
print(prog.strip())
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--cycles', type = int)
group = parser.add_mutually_exclusive_group()
group.add_argument('--halt', action = 'store_true')
group.add_argument('--blank', action = 'store_true')
group.add_argument('--spinout', action = 'store_true')
group.add_argument('--segment', action = 'store_true')
args = parser.parse_args()
if cycles := args.cycles:
CYCLES = cycles
if args.halt:
CANT_REACH = cant_halt
elif args.blank:
CANT_REACH = cant_blank
elif args.segment:
CYCLES = 20
CANT_REACH = segment_cant_halt # type: ignore[assignment]
with Pool() as pool:
pool.map(worker, sys.stdin)