]> git.sommitrealweird.co.uk Git - advent-of-code-2019.git/blobdiff - day7/part2.sh
Rename days to 2 digits always
[advent-of-code-2019.git] / day7 / part2.sh
diff --git a/day7/part2.sh b/day7/part2.sh
deleted file mode 100644 (file)
index 5f3c705..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash
-
-set -u
-set -e
-
-. "$(dirname $(readlink -f "$BASH_SOURCE"))/computer.sh"
-
-exec 3<input-full.txt
-
-OLDIFS=$IFS
-IFS="," read -u 3 -a orig_data
-IFS=$OLDIFS
-
-echo "Part 2:"
-
-run_amplifier() {
-    sequence=($@)
-    output=0
-    a=1
-    declare -a amps_stdin
-    declare -a amps_stdout
-    coproc amp1 (run_program orig_data)
-    coproc amp2 (run_program orig_data)
-    coproc amp3 (run_program orig_data)
-    coproc amp4 (run_program orig_data)
-    coproc amp5 (run_program orig_data)
-
-    for phase in ${sequence[@]}; do
-        amps_stdin[$a]="$(eval echo '${amp'${a}'[1]}')"
-        amps_stdout[$a]="$(eval echo '${amp'${a}'[0]}')"
-        echo -e "$phase\n$output" >&${amps_stdin[$a]}
-        read -u ${amps_stdout[$a]} output
-        a=$((a+1))
-    done
-
-    # that's all the amps started up, now we loop until amp1 stops, then we stop feeding amp5's
-    # data to it and read that's last output instead
-    while ( ps -p $amp1_PID >/dev/null 2>&1 ); do
-        for (( a=1; a<=5; a++ )); do
-            echo $output >&${amps_stdin[$a]}
-            read -u ${amps_stdout[$a]} output
-        done
-    done
-
-    echo "$output"
-}
-
-values="56789"
-biggest_output=0
-biggest_order="01234"
-for (( a=0; a<${#values}; a++ )); do
-    values_2="${values:0:$a}${values:$((a+1))}"
-    value_1=${values:$a:1}
-    for (( b=0; b<${#values_2}; b++ )); do
-        values_3="${values_2:0:$b}${values_2:$((b+1))}"
-        value_2=${values_2:$b:1}
-        for (( c=0; c<${#values_3}; c++ )); do
-            values_4="${values_3:0:$c}${values_3:$((c+1))}"
-            value_3=${values_3:$c:1}
-            for (( d=0; d<${#values_4}; d++ )); do
-                value_5="${values_4:0:$d}${values_4:$((d+1))}"
-                value_4="${values_4:d:1}"
-                output="$(run_amplifier $value_1 $value_2 $value_3 $value_4 $value_5 2>/dev/null)"
-                if [ $output -gt $biggest_output ]; then
-                    biggest_output=$output
-                    biggest_order="${value_1}${value_2}${value_3}${value_4}${value_5}"
-                fi
-            done
-        done
-    done
-done
-
-echo "Got biggest output $biggest_output with phases $biggest_order"
-
-exit 0
-
-output=0
-for val in 4 3 2 1 0; do
-    output=$(echo -e "$val\n$output" | run_program orig_data)
-done
-echo $output
-