15 if [ ${lastseen[$number]+a} ]; then
16 answers[$count]=$((count-${lastseen[$number]}-1))
33 if [ -n "$DEBUG" ]; then
34 debug_func="error_echo"
37 filename="${1:-p1_436.txt}"
48 for number in ${data[@]}; do
50 last_answer=$current_answer
51 if [ $last_answer -ge 0 ]; then
52 lastseen[$last_answer]=$((count-1))
54 answers[$count]=$number
55 current_answer=$number
58 while [ $count -lt 2020 ]; do
60 get_answer $current_answer $count
61 last_answer=$current_answer
62 lastseen[$last_answer]=$((count-1))
63 current_answer=${answers[$count]}
64 $debug_func "$count: ${answers[$count]}"
67 echo "Part 1: ${answers[$count]}"
69 while [ $count -lt 30000000 ]; do
71 get_answer $current_answer $count
72 last_answer=$current_answer
73 lastseen[$last_answer]=$((count-1))
74 current_answer=${answers[$count]}
75 $debug_func "$count: ${answers[$count]}"
78 echo "Part 2: ${answers[$count]}"