mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Clean up using shellcheck.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
sum1=0
|
||||
sum2=0
|
||||
|
||||
while IFS="\n" read line; do
|
||||
sorted=$(echo $line | xargs -n 1 echo | sort -n)
|
||||
while read -r line; do
|
||||
sorted=$(echo "$line" | xargs -n 1 echo | sort -n)
|
||||
checksum=$(($(echo "$sorted" | tail -n 1) - $(echo "$sorted" | head -n 1)))
|
||||
|
||||
for a in $sorted; do
|
||||
@@ -14,13 +14,13 @@ while IFS="\n" read line; do
|
||||
fi
|
||||
|
||||
if [[ $((a % b)) -eq 0 ]]; then
|
||||
sum2=$((sum2 + a / b))
|
||||
((sum2 += a / b))
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
sum1=$((sum1 + checksum))
|
||||
((sum1 += checksum))
|
||||
done
|
||||
|
||||
echo Sum 1: $sum1
|
||||
|
||||
Reference in New Issue
Block a user