From ec615662a47d3bdc295a47e0353d2811e9ae61e7 Mon Sep 17 00:00:00 2001 From: setop Date: Thu, 2 Dec 2021 09:03:37 +0100 Subject: [PATCH] day 2 --- d02/d02_1.awk | 5 + d02/input | 1001 +++++++++++++++++++++++++++++++++++++++++++++++++ d02/sample | 6 + 3 files changed, 1012 insertions(+) create mode 100644 d02/d02_1.awk create mode 100644 d02/input create mode 100644 d02/sample diff --git a/d02/d02_1.awk b/d02/d02_1.awk new file mode 100644 index 0000000..177aae2 --- /dev/null +++ b/d02/d02_1.awk @@ -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 } diff --git a/d02/input b/d02/input new file mode 100644 index 0000000..6b5457f --- /dev/null +++ b/d02/input @@ -0,0 +1,1001 @@ +forward 1 +down 5 +down 6 +down 2 +forward 8 +up 3 +up 2 +down 2 +forward 9 +forward 7 +down 2 +forward 5 +down 2 +forward 2 +forward 1 +down 8 +forward 5 +down 6 +up 9 +down 7 +forward 6 +forward 7 +forward 8 +up 3 +down 8 +forward 9 +forward 5 +forward 2 +down 3 +down 3 +down 6 +down 6 +down 8 +down 4 +forward 1 +up 9 +down 7 +up 6 +down 2 +down 8 +forward 1 +forward 7 +forward 4 +forward 1 +forward 7 +down 1 +down 9 +forward 6 +forward 6 +forward 7 +forward 3 +up 7 +forward 7 +up 1 +forward 3 +forward 4 +up 4 +forward 6 +down 8 +down 7 +forward 4 +up 6 +up 8 +down 5 +down 6 +forward 2 +forward 7 +forward 5 +forward 4 +down 5 +down 8 +down 4 +down 4 +down 3 +forward 3 +down 8 +forward 7 +up 6 +down 3 +down 7 +down 3 +forward 2 +up 8 +down 7 +down 6 +down 3 +up 5 +up 4 +down 2 +down 5 +up 9 +down 8 +up 7 +up 8 +forward 7 +down 9 +up 5 +down 5 +down 5 +up 4 +down 4 +up 3 +down 1 +down 4 +down 7 +forward 2 +forward 9 +up 8 +down 8 +forward 6 +forward 8 +down 6 +down 2 +forward 2 +forward 7 +up 7 +down 4 +forward 1 +down 4 +forward 2 +up 3 +forward 8 +forward 7 +forward 8 +down 2 +down 9 +down 5 +forward 7 +down 7 +forward 8 +forward 2 +up 2 +forward 9 +down 3 +up 7 +forward 2 +down 4 +up 3 +up 8 +forward 4 +forward 4 +forward 3 +up 3 +forward 5 +forward 5 +down 9 +down 4 +up 2 +down 8 +down 5 +down 8 +up 7 +down 3 +down 7 +up 9 +down 7 +up 5 +down 5 +forward 2 +forward 2 +forward 6 +down 4 +up 3 +forward 1 +forward 3 +forward 4 +down 2 +forward 2 +down 1 +down 2 +down 3 +forward 8 +forward 1 +down 5 +forward 3 +up 2 +down 2 +forward 3 +forward 1 +up 4 +up 1 +up 2 +forward 4 +forward 8 +down 7 +forward 2 +down 8 +forward 6 +forward 3 +up 7 +down 3 +down 3 +forward 7 +forward 9 +down 8 +down 8 +up 1 +up 8 +down 5 +up 3 +forward 6 +forward 4 +forward 8 +up 4 +down 6 +forward 2 +forward 8 +down 1 +up 5 +down 4 +forward 5 +up 1 +forward 2 +down 9 +down 2 +forward 8 +up 3 +up 7 +forward 3 +forward 4 +down 7 +up 3 +down 7 +forward 7 +up 1 +down 3 +down 5 +down 7 +forward 5 +down 1 +up 9 +forward 1 +down 6 +up 4 +down 1 +forward 7 +forward 2 +down 2 +forward 2 +down 7 +down 4 +down 7 +down 9 +down 6 +down 2 +up 6 +forward 8 +down 2 +down 1 +down 8 +down 8 +down 1 +down 7 +forward 4 +forward 1 +down 2 +down 1 +up 2 +down 5 +forward 3 +forward 7 +forward 9 +up 5 +down 7 +down 3 +forward 3 +down 4 +forward 6 +forward 1 +down 6 +up 5 +up 6 +down 9 +forward 9 +forward 5 +down 3 +forward 5 +up 4 +down 4 +down 6 +forward 2 +forward 2 +down 5 +down 1 +forward 3 +forward 5 +up 5 +down 1 +down 5 +down 3 +down 4 +down 2 +down 2 +forward 5 +down 1 +down 4 +down 6 +forward 4 +down 1 +down 1 +down 7 +forward 1 +down 5 +forward 6 +forward 7 +forward 3 +down 6 +forward 8 +down 8 +down 3 +up 9 +forward 3 +up 5 +forward 9 +forward 3 +forward 5 +down 3 +down 7 +down 5 +up 5 +down 1 +up 5 +down 5 +down 9 +down 4 +down 2 +down 2 +up 2 +up 1 +forward 2 +forward 4 +up 5 +down 1 +forward 6 +up 7 +up 5 +down 5 +forward 4 +down 1 +up 4 +down 2 +forward 3 +forward 4 +down 4 +down 8 +down 4 +up 3 +forward 6 +forward 3 +forward 1 +up 3 +forward 6 +down 1 +up 5 +down 5 +down 9 +down 9 +down 4 +forward 9 +down 6 +down 6 +forward 2 +up 7 +down 4 +down 4 +down 3 +up 1 +down 4 +up 2 +forward 9 +down 2 +down 6 +down 6 +up 5 +down 7 +down 6 +down 9 +down 8 +forward 5 +down 6 +up 3 +down 8 +up 3 +forward 5 +down 1 +forward 4 +forward 3 +down 9 +down 4 +forward 8 +forward 8 +up 4 +forward 7 +up 5 +down 9 +down 2 +forward 6 +down 4 +forward 9 +up 1 +down 7 +down 3 +forward 6 +up 7 +forward 2 +forward 1 +down 9 +up 4 +forward 2 +forward 6 +forward 9 +forward 9 +down 7 +forward 4 +down 2 +forward 1 +forward 8 +down 7 +down 1 +forward 5 +forward 5 +down 8 +up 8 +up 1 +forward 2 +down 8 +forward 6 +forward 1 +forward 2 +forward 7 +down 3 +forward 5 +up 6 +up 8 +down 7 +forward 2 +forward 5 +down 5 +forward 8 +down 6 +down 3 +up 2 +down 7 +forward 5 +down 4 +forward 3 +up 7 +up 6 +forward 4 +forward 7 +forward 6 +down 4 +forward 5 +up 3 +up 5 +down 8 +forward 7 +forward 2 +forward 3 +up 4 +down 1 +up 2 +up 1 +forward 6 +up 3 +down 3 +forward 7 +down 6 +forward 9 +forward 9 +down 7 +forward 1 +down 9 +down 9 +forward 8 +up 9 +up 7 +up 4 +forward 4 +down 3 +down 4 +forward 4 +forward 5 +down 2 +down 7 +down 1 +forward 7 +down 6 +down 6 +forward 3 +up 1 +forward 4 +down 5 +up 7 +up 3 +up 9 +forward 8 +up 4 +forward 2 +down 2 +down 2 +up 8 +forward 1 +forward 3 +forward 7 +down 7 +up 5 +down 3 +down 4 +down 6 +forward 5 +down 1 +forward 5 +down 4 +forward 8 +down 4 +forward 6 +forward 9 +down 5 +up 2 +down 2 +forward 1 +forward 5 +down 1 +down 4 +down 4 +up 6 +forward 7 +forward 2 +forward 9 +down 1 +forward 2 +forward 6 +forward 1 +up 9 +down 7 +down 8 +forward 3 +forward 5 +down 4 +forward 2 +forward 2 +up 8 +forward 3 +forward 8 +forward 5 +up 6 +forward 6 +forward 3 +down 4 +up 8 +down 3 +forward 4 +forward 3 +up 4 +forward 7 +down 9 +forward 3 +down 6 +forward 9 +down 8 +forward 6 +down 7 +down 1 +forward 9 +down 4 +forward 8 +forward 5 +forward 7 +up 5 +up 3 +down 8 +down 5 +down 2 +up 3 +up 7 +down 8 +forward 6 +forward 4 +forward 9 +forward 6 +forward 4 +forward 1 +down 1 +down 3 +up 3 +up 7 +down 9 +down 5 +forward 1 +forward 6 +forward 5 +down 9 +forward 9 +forward 5 +up 5 +forward 8 +forward 6 +forward 4 +down 4 +down 6 +down 1 +forward 1 +down 6 +forward 8 +down 3 +down 6 +down 5 +forward 3 +down 3 +down 8 +up 6 +forward 6 +down 6 +down 4 +down 8 +down 9 +down 3 +down 4 +down 5 +forward 4 +down 7 +down 8 +up 4 +forward 4 +down 9 +forward 1 +forward 1 +down 6 +up 3 +up 6 +down 8 +up 7 +forward 3 +down 6 +down 1 +down 4 +up 4 +down 9 +forward 1 +down 3 +up 1 +forward 8 +up 4 +up 6 +up 4 +down 4 +up 5 +up 3 +down 1 +down 6 +forward 9 +down 2 +forward 9 +forward 8 +down 2 +forward 8 +up 5 +forward 5 +forward 5 +forward 4 +up 8 +down 3 +forward 3 +down 4 +up 1 +forward 4 +up 7 +down 1 +down 4 +forward 1 +forward 9 +down 7 +forward 4 +down 5 +down 7 +forward 9 +down 2 +down 2 +down 1 +down 2 +forward 8 +down 6 +forward 5 +down 2 +down 1 +up 4 +forward 7 +down 1 +down 5 +down 7 +down 6 +down 6 +up 8 +forward 3 +up 8 +up 9 +down 2 +down 1 +down 5 +up 8 +forward 4 +forward 6 +down 2 +down 3 +forward 2 +forward 2 +forward 2 +forward 3 +down 7 +forward 3 +down 4 +up 1 +down 2 +down 9 +up 4 +down 8 +up 7 +down 6 +down 7 +down 6 +forward 6 +down 4 +forward 2 +down 7 +down 1 +forward 2 +forward 5 +forward 6 +down 1 +down 4 +forward 2 +down 4 +down 6 +down 8 +forward 9 +down 8 +forward 5 +down 7 +forward 5 +up 1 +down 1 +down 9 +down 3 +forward 3 +forward 5 +down 6 +forward 6 +up 3 +down 4 +down 4 +forward 7 +forward 3 +down 5 +down 3 +forward 7 +up 5 +forward 1 +down 6 +forward 1 +forward 9 +forward 9 +up 9 +forward 5 +up 5 +forward 6 +down 8 +up 4 +up 8 +forward 9 +forward 4 +down 5 +down 2 +down 9 +forward 3 +forward 6 +forward 2 +up 4 +down 4 +forward 3 +down 8 +down 3 +up 3 +forward 8 +down 4 +forward 4 +forward 4 +up 9 +down 1 +up 5 +up 5 +forward 8 +forward 4 +forward 5 +forward 1 +forward 3 +forward 8 +down 1 +forward 2 +forward 7 +down 4 +down 3 +down 4 +up 7 +forward 9 +forward 7 +down 8 +forward 2 +down 4 +up 9 +down 9 +down 9 +up 2 +down 9 +down 9 +down 6 +up 9 +up 6 +down 7 +forward 3 +forward 9 +forward 2 +down 4 +up 4 +forward 1 +up 1 +down 6 +down 3 +down 2 +up 6 +down 5 +down 8 +up 4 +forward 1 +down 1 +down 4 +down 8 +down 5 +forward 2 +down 5 +forward 3 +forward 1 +forward 9 +forward 4 +down 6 +down 4 +down 3 +forward 5 +forward 4 +down 1 +up 7 +down 4 +up 3 +forward 2 +forward 4 +up 2 +up 9 +forward 4 +down 5 +forward 9 +up 1 +forward 8 +down 9 +down 6 +down 6 +down 2 +down 2 +down 3 +forward 8 +down 2 +down 5 +forward 4 +up 3 +down 4 +up 6 +forward 7 +up 2 +down 6 +down 8 +forward 1 +down 8 +down 9 +down 2 +forward 3 +forward 9 +up 7 +down 1 +down 5 +up 7 +down 5 +up 8 +up 4 +down 6 +forward 1 +forward 6 +forward 9 +forward 6 +forward 6 +forward 9 +forward 8 +down 8 +down 8 +down 4 +down 7 +down 9 +up 9 +down 7 +down 2 +forward 2 +down 5 +down 3 +down 1 +down 4 +down 2 +down 1 +up 2 +forward 6 +down 3 +down 3 +down 1 +forward 8 +down 3 +forward 1 +forward 3 +down 1 +up 7 +down 9 +forward 5 +forward 8 +up 7 +down 4 +down 3 +down 1 +forward 2 +forward 9 +up 5 +down 2 +forward 6 +forward 6 +forward 2 +forward 1 +forward 1 +down 9 +forward 6 +forward 6 +down 2 +down 6 +up 5 +forward 5 +up 4 +forward 4 +down 2 +down 2 +down 7 +down 1 +down 4 +forward 3 +forward 3 +up 8 +down 8 +forward 5 +up 4 +up 9 +up 6 +up 6 +down 7 +forward 2 +up 1 +forward 2 +forward 4 +forward 4 +forward 2 +forward 4 +down 6 +down 3 +forward 9 +forward 3 +down 2 +forward 6 +forward 6 +forward 4 +forward 8 +up 1 +down 1 +forward 1 +down 7 +up 6 +up 8 +down 1 +down 4 +down 3 +up 4 +forward 4 +forward 5 +down 5 +down 8 +up 7 +down 2 +down 6 +forward 5 + diff --git a/d02/sample b/d02/sample new file mode 100644 index 0000000..b7172ac --- /dev/null +++ b/d02/sample @@ -0,0 +1,6 @@ +forward 5 +down 5 +forward 8 +up 3 +down 8 +forward 2