diff options
Diffstat (limited to '2015/03/puzzle-1.awk')
-rw-r--r-- | 2015/03/puzzle-1.awk | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/2015/03/puzzle-1.awk b/2015/03/puzzle-1.awk new file mode 100644 index 0000000..13b1209 --- /dev/null +++ b/2015/03/puzzle-1.awk @@ -0,0 +1,6 @@ +BEGIN { x = y = 1; homes[x][y] = 1; acc = 1 } +$0 == "^" { if (!homes[x][++y]++) acc++; next } +$0 == ">" { if (!homes[++x][y]++) acc++; next } +$0 == "v" { if (!homes[x][--y]++) acc++; next } +$0 == "<" { if (!homes[--x][y]++) acc++; next } +END { print acc } |