summaryrefslogtreecommitdiffstats
path: root/2019/day7/comm.py
blob: 458d8b17fd99e3e5df4fa380033ca8559496cb7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from itertools import permutations
import os
import subprocess

perm = permutations(range(5))
res = []

for seq in perm:
    signal = 0
    for phase in seq:
        out = subprocess.run(
            ["perl", "intcode.pl", "part1.in"],
            capture_output=True,
            input=b"%d\n%d" % (phase, signal),
        )
        signal = int(out.stdout)
    res.append(signal)

print(sorted(res)[-1])