3 # read the file straight in for gits and shiggles
5 read -a data -d $'\0' < input.txt
7 echo "Got ${#data[*]} records"
9 for a in $(seq 0 $((${#data[*]}-3))); do
10 progress=$(($((a * 100)) / ${#data[*]}))
11 echo -ne "\r${progress}% through"
12 for b in $(seq $((a+1)) $((${#data[*]}-2))); do
13 for c in $(seq $((a+2)) $((${#data[*]}-1))); do
14 if [ $((${data[$a]} + ${data[$b]} + ${data[$c]})) -eq 2020 ]; then
15 echo -e "\r100% done "
16 echo "Match found: ${data[$a]} + ${data[$b]} + ${data[$c]} = 2020"
17 echo "Multiplied: $((${data[$a]} * ${data[$b]} * ${data[$c]}))"