aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorj-james2020-12-03 06:50:47 +0000
committerj-james2020-12-03 08:24:42 +0000
commitf43e27cd290b652bdcf46c88fdf0bac585d7d58c (patch)
treeb766b00a0641cbebc76a2b9c35eb2e39746fdab0
parentca62f5d0ae8a96c5d85d3a447a00150d186be605 (diff)
Day Three
-rw-r--r--2020/input/three.txt323
-rw-r--r--2020/three.nim14
2 files changed, 337 insertions, 0 deletions
diff --git a/2020/input/three.txt b/2020/input/three.txt
new file mode 100644
index 0000000..6e5de58
--- /dev/null
+++ b/2020/input/three.txt
@@ -0,0 +1,323 @@
+...........#..#.#.###....#.....
+...#..#...........#.#...#......
+#.....#..#........#...#..##....
+..#...##.#.....#.............#.
+#.#..#......#.....#....#.......
+.....#......#..#....#.....#....
+.......#.#..............#......
+.....#...#..........##...#.....
+...#....#.#...#.#........#...#.
+..#.........###.......##...##..
+.#....#...........#........#..#
+..#.............##.............
+..#.##.#....#................#.
+.....##.#.......#....#...#.....
+......#.#....##................
+..#..........###..#..#.#..#....
+....#..............#....##..#.#
+.#.........#.#....#.#.#....#...
+..#.....#......##.#....#.......
+..#.#....#..#.#...##....###....
+...#......##...#........#.#..#.
+.##.#.......##....#............
+...##..#.#............#...#.#..
+.##...##.#..#..................
+..#......##......#......##.....
+.....##...#..#...#.........#...
+.##.#.....#..#..#.##....##....#
+..#.#......#.......##..........
+......................#......##
+##.#...#.................#.#.#.
+......#.#..........#.....##.#..
+#.#......#.....#...........#...
+.....#...#.......#..#..#.#...#.
+...........#......#.#...#......
+....##...##...........#......#.
+.........#.##..................
+......#...#....#......##.##...#
+......#...#.#########......#...
+.......#.#...#.......#..#......
+............#...#...#.###...##.
+...........#..........#...#....
+...#..#.#................#.#..#
+..#....#.....#.............#.#.
+....##......#........#....#....
+........##...............#....#
+........#..#...#..............#
+...#....#.#...#..#...#....#.#.#
+.........#.......#....##.......
+#.##..............#.#........##
+......................###......
+.........#....##..##....#.#.#..
+.#...##.#.#...#....##..#.....#.
+....................#.#......#.
+.#..#.......................#..
+..#..#.............#..#....#...
+...#...#..#...#...#.#..#.##....
+........#....#...#....#........
+.#.....#........#.........#...#
+...#......#..#..#..####..#.....
+#....#..............#.##.......
+.#....#.............##...#.....
+....#...#.##........##......#..
+##....#...#.......#..#........#
+....##........................#
+..................#..#.........
+..#....#........#..#.......#...
+#...#..#....#...##...........#.
+.........#..#..#.#.##..........
+....#.#..#.....#..#.#.#.#..#.##
+##................#.##.....#...
+.#.....###..#..#..#.....#....##
+...#...........#..........####.
+.#.....#....#......#.##..#.#...
+..#...##....#................#.
+........#.......#......#.#.....
+....#.#.#.#....#...#......#..#.
+...........#......#..#.........
+###...##......##.#..#....##....
+##....##.........#..#....###...
+#.#.....#....#......#...#..##..
+#....##.#..............#.##....
+.#........#.#.........#...#....
+......................#......#.
+........#..#..##.....#..#.#....
+..#...###.................#..#.
+...#...#............#..........
+.##.......#..#.........#....#..
+.#..............#....#....##...
+...............##..#.#.......##
+.#.....#....#...#..#.......#..#
+#..#.............#....#......#.
+.....#.#......#.........###..#.
+.#...#.#...............#....#..
+#......#.............#.........
+.#.##.#.####...#..#.##..#.....#
+.....#......#..#...#.......#...
+#........###...#.....#..#.....#
+....#.#.....#...#..........#...
+...#.#.......#.#......#..#.##..
+..#..........#.#..#.......#.#..
+#...#.#..............#...###.#.
+...#..#...#............###.....
+..#..#...#.#............#..#...
+.###.#.....................#..#
+....#....#..#.....##.##........
+#....#....#.#..#.........#.....
+.#.....##....#............##..#
+#....#.#...#...#..#.#......#...
+#.....##.....##.....##.#...##..
+...##...#..#..####.#........#..
+.........#...#......##..##..#..
+..#.....###.#..#..####.#.......
+.......#......#...#..##....#...
+.#.....#.#.#..#....#...#..##...
+..........#.#...#...#.#..#.....
+....#.....#........#.....##..#.
+..#.#.##.........#...##.....##.
+.........#.##....#............#
+............##.....#.......#.#.
+......#.....#...#..#..###......
+##.....#.......#...##.#....#...
+...........##......#..##...#.#.
+..#.#.#.#...#.......#....#...#.
+#.............#.....#.#...###..
+##....#.......#.....#..##.#....
+...#.......#....#.........##...
+......#.......#......##.##.....
+..#......#...#.#........#......
+....#.#....#.#.##......#.....#.
+#......#.........#..#....#.....
+........#..#....##.....#.......
+#......##....#.##....#......#..
+..#.......#............##.....#
+...........#...#...........#...
+#.......#...#....#....#...#.#.#
+..###..#........#........#.....
+..#..###...........#.#......#..
+.#...........#......#..........
+.#.......#.....#.......#.......
+..#......##.#............#....#
+#..........#.....#.#..#........
+.....#...##.##.......#......#..
+..........#.....#........#.#.#.
+....#......#.....#......#.#....
+.........#.#.#..#...##....#...#
+.........#.......#...##...#.#..
+.##........#...............#...
+.......#....#...........##.....
+.........###......#.........#.#
+......#.......#...#..........#.
+...#.#..........##......#...#..
+#.......#.#..........#.........
+................#..#......#..##
+.....#...#....#.#.....#........
+#.....#....#...........#....#..
+#....#.#..#...##....#...##.#...
+...#.....#......#.#....#..#..#.
+..#................#...#.#..##.
+..........#..............#..#.#
+.....##.....#..#.###...........
+....#.#......#.#...........#...
+.#....#.#.........##.#....#....
+.#.#........#........###....#..
+##.#................#...#..#...
+.......#......##..#.....#..#.#.
+...#............#......###...##
+#.#...........#.........#......
+.....#.#.#.................#...
+....#..............#...#.#.....
+...#.#.....##..#...............
+.#..##...#....##.....###..#....
+...............#...#...#.#.###.
+.###....#.....#...#.#......#...
+...#..#.....#.......#..##.#....
+...........#..#....##..#...#...
+...#...#..........#.......##.#.
+............#.#.......#........
+....#.........#.....#..........
+...#.###.##..#...##..####..#..#
+.#.#...#..#...................#
+.....#..#.....##..#............
+....#......#...##..#.##........
+...#...............#..#.....##.
+...#......#.........#.#..##....
+.#....#.##.......#......#......
+....#.......#....#..........#..
+#.#.#....###.#.#.............#.
+..##..###........#.#..#.#..#...
+......#.#............##.#...###
+.........#.#....#####.....##...
+............##......#.#..#.....
+...#.....#.....###....#........
+##..........####.##.#.#........
+....................##.....##.#
+#.#............#........#......
+....#...##.....#......#....#...
+...###.#..##..................#
+..###......#..............#.#.#
+.#...#...........#....#........
+....#............#..#..#.#.....
+...#.........#.#.........#.####
+..#...#...#...#...........#....
+...............#.#......##..#..
+#....#.#.......#.#..#......#..#
+........#.#....#..#...#..#...#.
+...#..#.......#...........#....
+...........#.......#...........
+.#......#................#.....
+....#.#.#...#......#..#...#....
+................#.#.#....#.....
+.........................##..#.
+.#...........#............##...
+#...............#.....##.#.#..#
+.........#.......###....#.....#
+....##...#...#.....#..#........
+........#.....#..#.#.#...#..#..
+......#.......#.#.........#.#..
+#......#............#...#....#.
+#..##...#..#................#..
+.##...#...#.....#.##.......#..#
+.......#.##........##..##......
+##.#..##...............#.....#.
+......#....#..##...#......###.#
+#........##..#....#.#......#...
+.#......##.#...#.#...#.........
+.#.#...#..#.............#......
+.##..........#..........#......
+.#.....#.....#..............#.#
+..#.........#..#.#.....#.#....#
+..#.##..............##...#..###
+....................#..........
+......###..#..#...........#....
+..#..........#.......#...#.....
+...#......#......#.............
+....##..............#.#.....#..
+........#.#......#..#........##
+.............#...#.#.........##
+...###...#..........##.......#.
+.#..........#...##..#.#.....#..
+##...#.........#...............
+......#....#....#.....#.....#..
+..........#....#...#...#..#...#
+...##....#.#.#..#...##.........
+#......#.#...##.###...#....#...
+##.......##.#......##..#...#...
+......#.............#.##.....##
+#.......###....####.#...##....#
+..#...#..#.......#..........#..
+#.....#..#..#..#.##...###...#..
+.....##.#..#..#..#.#....#...#..
+..#...#..................##....
+....#.#........##..............
+#...#.......##...#...#.#.......
+..#...#........##....#.#.......
+..........###...###...#......#.
+#.....#..###...##...##..#..#..#
+..#.....##.....#.......##..#.#.
+........#........#.........#...
+.................#....#.......#
+.......#...#.....#...#.#.......
+....##...............#...##...#
+.##...#................#...#...
+.............#.................
+.#..#....#....#.#....#.........
+.#.#..#..........#.......#.....
+.....##.....##...#..#..........
+#...#.#.........#......#..#....
+........#....#...#....#.#.##...
+....#..#........#...#...#......
+.#..#.....#.#...#.........#....
+.#..#..#...........#..#....#...
+....###.............#..#.......
+#......#..#..##..........#.#...
+#..#..#.##..#...#.#.#..........
+....###......#.##.....#....#...
+.##..#...#......##.#...........
+..#..#.......#.....#.##....#.#.
+.......#.#.#........#....##....
+..##...#....#...............###
+#..##..#...........#.#....##...
+...##..#.....................#.
+###......#....#....###..#...##.
+.........##............#..#...#
+..#..........#...#.#.#......#.#
+.......#.....##..##......#.##..
+#..........#.....##.#..........
+#.......#.#...#...#....#.......
+#...#.....##.......#.#..#.#.#..
+.........#.#.#..#..#...#.###...
+.................##...#....#...
+###.......#..........##...#....
+#.#..#.........#....##.#.......
+......#.#.....#........#.......
+.......#.#........#......#.#..#
+..............#..#...##....#..#
+#...........#...##.....#..#.#..
+..#....#..#.#.#...#..#....#.#..
+...##.#.....#..#...##..#.....#.
+..#.#................#........#
+......#...#.............#......
+.##............#....#...#..#...
+....#...#...........#.......#..
+.###..#.......#.............#.#
+.#.#....#.#...........#.#......
+...#.........#.........#..#....
+...#..........#.#.....#.#......
+.....#........#....##......#...
+..#.#.#......#..#.#......#....#
+.#.#..#................#.#.....
+.#.#.........##...#.......#.#.#
+#..#.....#...#..#...........#..
+..##......####......#..#....###
+#.....###....#.#........#..#..#
+..##.#...#.#..##..........#..#.
+#.........#.#.............#...#
+...#.#...#...#.#.#....##.......
+##.##...#.....#...#...........#
+....#........#.#.....#.........
+.................##..#..##...##
+.....##....#...#...#.....#..#..
+....#...#........#............#
+..#...........##....#...#...##.
+.....#......#.........#..##.#..
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)