]> git.sommitrealweird.co.uk Git - advent-of-code-2020.git/blob - day01/find_2020_factors.sh
Day 13 - forays in to using Diophantine did not go well.
[advent-of-code-2020.git] / day01 / find_2020_factors.sh
1 #!/bin/bash
2
3 # read the file straight in for gits and shiggles
4 declare -a data
5 read -a data -d $'\0' < input.txt
6
7 echo "Got ${#data[*]} records"
8
9 for a in $(seq 0 $((${#data[*]}-2))); do
10     for b in $(seq $((a+1)) $((${#data[*]}-1))); do
11         if [ $((${data[$a]} + ${data[$b]})) -eq 2020 ]; then
12             echo "Match found: ${data[$a]} + ${data[$b]} = 2020"
13             echo "Multiplied: $((${data[$a]} * ${data[$b]}))"
14             exit 0
15         fi
16     done
17 done