aoc2021/d02/d02_1.awk

6 lines
133 B
Awk
Raw Normal View History

2021-12-02 08:03:37 +00:00
BEGIN { h = 0; d = 0; a = 0; }
$1 == "forward" { h+=+$2; d+=+$2*a; }
$1 == "up" { a-=+$2 }
$1 == "down" { a+=+$2 }
END { print h*d }