advent-of-code/12021/01/01_2_new.awk

14 lines
270 B
Awk

# reading the lines as fields of one record,
# simplifying the comparison
# and accumulating the result of the comparison
# awk -c -f 01_2_new.awk 01input.txt
BEGIN{
RS = "" # empty line(s) as RS
}
{
for(i=1;i<=NF-3;i++){
count += $(i+3) > $i
}
}
END{ print count }