diff options
-rw-r--r-- | 2020/input/three.txt | 323 | ||||
-rw-r--r-- | 2020/three.nim | 14 |
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) |