From edface94833462d5ccb3496ed631b2d3815646ec Mon Sep 17 00:00:00 2001 From: cos Date: Sat, 7 Dec 2019 23:09:12 +0100 Subject: Add day07, 2019 Solution search is implemented as shell scripts. Ugly and fragile, but it got the task done. --- 2019/rust/day07/calibrate_amplifiers.sh | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 2019/rust/day07/calibrate_amplifiers.sh (limited to '2019/rust/day07/calibrate_amplifiers.sh') diff --git a/2019/rust/day07/calibrate_amplifiers.sh b/2019/rust/day07/calibrate_amplifiers.sh new file mode 100755 index 0000000..917dfa7 --- /dev/null +++ b/2019/rust/day07/calibrate_amplifiers.sh @@ -0,0 +1,36 @@ +#!/bin/sh -e + +H=0 +I=0 +P="" +for A in `seq 0 4`; do + for B in `seq 0 4`; do + for C in `seq 0 4`; do + for D in `seq 0 4`; do + for E in `seq 0 4`; 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=`RUST_BACKTRACE=1 ../target/debug/day07 \ + --mode arg --program input "${A},${I},${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}" -- cgit v1.2.3