6 IFS="," read -u 3 -a orig_data
12 data=("${orig_data[@]}")
16 while [ $pos -le ${#data[@]} ]; do
17 loc1=${data[$((pos+1))]}
18 loc2=${data[$((pos+2))]}
19 res_loc=${data[$((pos+3))]}
22 data[$res_loc]=$((${data[$loc1]}+${data[$loc2]}))
25 data[$res_loc]=$((${data[$loc1]}*${data[$loc2]}))
31 echo "Invalid opcode: ${data[$pos]} at position $pos"
40 echo "Part 1: $(run_program 12 2)"
42 desired_output=19690720
44 for (( noun=0; noun < 100; noun++)); do
45 for (( verb=0; verb < 100; verb++)); do
46 if [ $(run_program $noun $verb) -eq $desired_output ]; then
47 echo "Part 2: $((noun * 100 + $verb)) $noun, $verb"