Initial Commit - days 01-12

This commit is contained in:
2020-12-21 14:58:15 +01:00
commit 11844d1904
131 changed files with 16060 additions and 0 deletions

23
day01/ex1.bash Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
#
# ex1.bash: Advent2020 game, day 1/game 1
CMD=$(basename "$0")
readarray -t numbers
declare -i i j a b
for ((i=0; i<${#numbers[@]}; ++i)); do
a=$((numbers[i]))
for ((j=i+1; j<${#numbers[@]}; ++j)); do
b=$((numbers[j]))
if ((a+b == 2020)); then
printf "${CMD} : %d:%d %d:%d sum=%d mul=%d\n" \
$i $a $j $b \
$((a+b)) $((a*b))
break 2
fi
done
done
exit 0