cleanup code

This commit is contained in:
2022-12-01 10:48:09 +01:00
parent a8cab0c7c3
commit ce446be296

View File

@@ -15,7 +15,7 @@
declare -a total
declare max=0
declare -i res
declare -i res=0
parse() {
local -i elf=0
@@ -36,18 +36,15 @@ part1() {
part2() {
local -i i elf newbest
res=0
for ((i=0; i<3; ++i)); do
newbest=0
for ((elf=0; elf<${#total[@]}; ++elf)); do
if (( total[elf] > total[newbest] )); then
newbest=$elf
fi
(( total[elf] > total[newbest] )) && newbest=$elf
done
(( res+=total[newbest] ))
unset "total[$newbest]" # remove current max
total=("${total[@]}") # pack array
#printf "%d: %s\n" "$i" "${total[*]}"
done
}