summaryrefslogtreecommitdiffstats
path: root/2019/day7/comm.py
diff options
context:
space:
mode:
Diffstat (limited to '2019/day7/comm.py')
-rw-r--r--2019/day7/comm.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/2019/day7/comm.py b/2019/day7/comm.py
new file mode 100644
index 0000000..458d8b1
--- /dev/null
+++ b/2019/day7/comm.py
@@ -0,0 +1,19 @@
1from itertools import permutations
2import os
3import subprocess
4
5perm = permutations(range(5))
6res = []
7
8for seq in perm:
9 signal = 0
10 for phase in seq:
11 out = subprocess.run(
12 ["perl", "intcode.pl", "part1.in"],
13 capture_output=True,
14 input=b"%d\n%d" % (phase, signal),
15 )
16 signal = int(out.stdout)
17 res.append(signal)
18
19print(sorted(res)[-1])