8000 9: Use negative index for last array entry · einarjon/adventofcode.sh@60e5242 · GitHub
[go: up one dir, main page]

Skip to content

Commit 60e5242

Browse files
committed
9: Use negative index for last array entry
1 parent dad2caa commit 60e5242

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

09.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ while [ "$sum" != "${A[i]}" ]; do
2121
[[ $j -ge $i ]] && echo NOT FOUND && break
2222
done
2323
B=($(printf "%s\n" "${A[*]:k:j-k+1}" | sort -n))
24-
echo "9B: $j..$k = $((B+B[${#B[@]}-1]))"
24+
echo "9B: $k..$j = $((B[0]+B[-1]))"

0 commit comments

Comments
 (0)
0