blob: 25067467c56d18058cde692875225623acc5ba5f (
plain)
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
|
#!/bin/sh -e
launch_chain()
{
local input_file="input_$1_$2_$3_$4_$5_$6.txt"
local p="input"
(echo ${6}; (echo ${5}; (echo ${4}; (echo ${3}; (echo "${2}
${1}" > "${input_file}";tail -f "${input_file}")| \
../target/release/day07 --mode stdio --program "${p}") | \
../target/release/day07 --mode stdio --program "${p}") | \
../target/release/day07 --mode stdio --program "${p}") | \
../target/release/day07 --mode stdio --program "${p}") | \
../target/release/day07 --mode stdio --program "${p}" >> "${input_file}"
tail -1 "${input_file}"
}
H=0
I=0
P=""
for A in `seq 5 9`; do
for B in `seq 5 9`; do
for C in `seq 5 9`; do
for D in `seq 5 9`; do
for E in `seq 5 9`; do
[ ${A} -ne ${B} ] || continue
[ ${A} -ne ${C} ] || continue
[ ${A} -ne ${D} ] || continue
[ ${A} -ne ${E} ] || continue
[ ${B} -ne ${C} ] || continue
[ ${B} -ne ${D} ] || continue
[ ${B} -ne ${E} ] || continue
[ ${C} -ne ${D} ] || continue
[ ${C} -ne ${E} ] || continue
[ ${D} -ne ${E} ] || continue
O=`launch_chain ${I} ${A} ${B} ${C} ${D} ${E}`
V=`echo "${O}" | tail -1 `
[ "${H}" -ge "${V}" ] || {
P="${A},${B},${C},${D},${E}";
H="${V}";
HI="${I}";
}
done
done
done
done
done
echo "Highest value: ${H} for phase set ${P}"
|