My solutions to the advent of code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
335 B

3 years ago
#!/usr/bin/env bash
# Give file as option 1
file="$1"
increasing=0
readarray -t "arr" < "$file"
length="${#arr[@]}"
for i in $(seq 3 "$length"); do
curr="${arr[$i]}"
prev3="${arr[$((i - 3))]}"
if [ -n "$curr" ] && [ "$curr" -gt "$prev3" ]; then
increasing="$((increasing + 1))"
fi
done
echo "$increasing were increasing"