6 . "$(dirname $(readlink -f "$BASH_SOURCE"))/computer.sh"
11 IFS="," read -u 3 -a orig_data
19 for phase in ${sequence[@]}; do
20 output=$(echo -e "$phase\n$output" | run_program orig_data)
28 for (( a=0; a<${#values}; a++ )); do
29 values_2="${values:0:$a}${values:$((a+1))}"
30 value_1=${values:$a:1}
31 for (( b=0; b<${#values_2}; b++ )); do
32 values_3="${values_2:0:$b}${values_2:$((b+1))}"
33 value_2=${values_2:$b:1}
34 for (( c=0; c<${#values_3}; c++ )); do
35 values_4="${values_3:0:$c}${values_3:$((c+1))}"
36 value_3=${values_3:$c:1}
37 for (( d=0; d<${#values_4}; d++ )); do
38 value_5="${values_4:0:$d}${values_4:$((d+1))}"
39 value_4="${values_4:d:1}"
40 output=$(run_amplifier $value_1 $value_2 $value_3 $value_4 $value_5)
41 if [ $output -gt $biggest_output ]; then
42 biggest_output=$output
43 biggest_order="${value_1}${value_2}${value_3}${value_4}${value_5}"
50 echo "Got biggest output $biggest_output with phases $biggest_order"
55 for val in 4 3 2 1 0; do
56 output=$(echo -e "$val\n$output" | run_program orig_data)