day 2, parts 1 & 2
This commit is contained in:
parent
ec615662a4
commit
62275676a3
|
@ -1,5 +1,5 @@
|
|||
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 }
|
||||
BEGIN { h = 0; d = 0}
|
||||
$1 == "forward" { h+=+$2 }
|
||||
$1 == "up" { d-=+$2 }
|
||||
$1 == "down" { d+=+$2 }
|
||||
END { print h, d, h*d }
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
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 }
|
Loading…
Reference in New Issue