rename repo, subdir for yearly challenges
This commit is contained in:
23
2020/day01/ex1.bash
Executable file
23
2020/day01/ex1.bash
Executable 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
|
Reference in New Issue
Block a user