aboutsummaryrefslogtreecommitdiff
path: root/2019/07/puzzle-2.sh
blob: 4a034f763d66d40f42db3cba37721e44d01f3eba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

mkfifo pipe
trap 'rm pipe' EXIT

python -c '
import itertools
for p in itertools.permutations([5, 6, 7, 8, 9]):
	print(*p)
' | while read a b c d e
do
	  ./machine.lisp $a 0 <pipe                 \
	| ./machine.lisp $b                         \
	| ./machine.lisp $c                         \
	| ./machine.lisp $d                         \
	| ./machine.lisp $e                         \
	| tee pipe                                  \
	| tail -n1
done | sort -nr | head -n1