aoc2021/d02/d02_1.awk

6 lines
119 B
Awk

BEGIN { h = 0; d = 0}
$1 == "forward" { h+=+$2 }
$1 == "up" { d-=+$2 }
$1 == "down" { d+=+$2 }
END { print h, d, h*d }