aboutsummaryrefslogtreecommitdiff
path: root/2020/three.nim
diff options
context:
space:
mode:
Diffstat (limited to '2020/three.nim')
-rw-r--r--2020/three.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/2020/three.nim b/2020/three.nim
new file mode 100644
index 0000000..8455783
--- /dev/null
+++ b/2020/three.nim
@@ -0,0 +1,14 @@
+import os, strutils, std/enumerate
+
+let input: string = paramStr(1)
+
+proc descend(x: int, y: int): int =
+ var longitude: int = 0
+ for i, latitude in enumerate(lines(input)):
+ if i mod y == 0:
+ if latitude[longitude mod len(latitude)] == '#':
+ inc(result)
+ longitude += x
+
+echo descend(3, 1)
+echo descend(1, 1) * descend(3, 1) * descend(5, 1) * descend(7, 1) * descend(1, 2)