From f43e27cd290b652bdcf46c88fdf0bac585d7d58c Mon Sep 17 00:00:00 2001 From: j-james Date: Wed, 2 Dec 2020 22:50:47 -0800 Subject: Day Three --- 2020/input/three.txt | 323 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2020/three.nim | 14 +++ 2 files changed, 337 insertions(+) create mode 100644 2020/input/three.txt create mode 100644 2020/three.nim (limited to '2020') 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) -- cgit v1.2.3-70-g09d2