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

20 lines
212 B
Awk

# awk -c -f 01_2.awk 01input.txt
BEGIN{
count = 0
}
{
a[NR] = $1
}
END{
for(i=1;i<=length(a)-3;i++){
x = a[i] + a[i+1] + a[i+2]
y = a[i+1] + a[i+2] + a[i+3]
if( y > x )
count++
}
print(count)
}