diff options
author | Yigit Sever | 2021-12-13 10:40:39 +0300 |
---|---|---|
committer | Yigit Sever | 2021-12-13 10:40:39 +0300 |
commit | bf16b19b1f6deffd1983efca059db576f3b60ee5 (patch) | |
tree | 1262f68d8eb2c326684d395aebcd5a1cc0b0f748 /2019/day7/comm.py | |
parent | 74b27ccca31bb757c737dd7fdc02f513f57561b2 (diff) | |
download | aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.tar.gz aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.tar.bz2 aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.zip |
2019, tracking
Diffstat (limited to '2019/day7/comm.py')
-rw-r--r-- | 2019/day7/comm.py | 19 |
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 @@ | |||
1 | from itertools import permutations | ||
2 | import os | ||
3 | import subprocess | ||
4 | |||
5 | perm = permutations(range(5)) | ||
6 | res = [] | ||
7 | |||
8 | for 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 | |||
19 | print(sorted(res)[-1]) | ||