diff --git a/2020/3/input b/2020/3/input new file mode 100644 index 0000000..1c7e862 --- /dev/null +++ b/2020/3/input @@ -0,0 +1,323 @@ +.........###......#...#.......# +.#.#...........#..#..#......... +#.......#.................#.... +.........#.#.........#......### +.....#......##...##............ +...##...#......#.....#.....##.. +#.#..#....#...#....#......#.... +........##.....#.....#.#....... +......#.....#......#...##.#.... +...####...#.......##.....#.#... +.........#....#......##........ +..##...........###.#........... +.....#............#............ +#.#..#..##........#.....#..#... +.....................#....##..# +...........##.....###...#.#.#.. +..#......#...........#......... +.##.##...#...#......##.#....... +......#..#......#.#.#..#.#..... +........#.#..#..........#...#.# +...........##...........#....#. +...........#...##.#............ +.......#...........#........... +.......#......#..#...#....#..#. +..#.....#.#....#.#......#...#.# +.#..........###..#....#........ +........##..#..#...#..#....#..# +#..........#...#..#.#........#. +..#.#........##.##....##.#..... +#.##....#...#.......#.#..#....# +......##...#.#.#.#.....#....#.. +..........#..............#..... +....................###.#...... +#.....#...#...#.#.......#....#. +.......#..#...................# +........##.##........#......#.. +...#...##.#...#...........#.... +..#.........#...#....##......#. +......#..............#..#..#.#. +.....##...#...#...##....#...... +#.#....#...#......##.....#...## +.#...#.#..................#.... +#.##.....#......#..........#... +..#..#.......#................. +..#.....#.........#........#... +.......#...##.##.#..#..##.#..#. +#.............#.........#.#.... +..#..##..........#..#..##.#.#.. +.#......#.......#...#.....##.#. +.....#......#...#...........### +..........#.........#.....#.... +.....#..........#.......##...#. +......#..#..#..............#... +.#.####..#...##...#.#.......... +..#....#.......#........#.....# +....#.##.....#..#.....#.#.#..#. +.......#..#..##.......#........ +.#.....#...........#.....#..... +........#..........##..##.#.... +.#.....#........#.....#..#..... +..#..........#...#......##..#.. +.#............#.........#....#. +........#..###.......#.....###. +##.#...#.#..#..#..#.#.##...#... +.#....#...#..#......##......... +.............##.....##......... +.....##.#..###.#....#...#...#.# +#........#...#......#...#.##... +#....#......#.....###.##.#..... +.....#..#.#.##....#..##.....##. +....#...#...#..........##...... +..........#......#...#.....##.. +.....##....##.#.............#.# +#.........#.##.............#..# +.....#.........##.#...#.#.#.... +..........#..#......#..#.....#. +....#....#....#....#.......###. +....#...#..##....#..##..#...##. +.###......#...........###...... +#..................####.#....#. +#....#.#.....#.#....#..#....... +...#......#....##......#..#..#. +#.#...#.##.....#.#.......##..#. +.........##.................#.. +#..##.#....#.#.............#... +....................####.#.#..# +.......#..#...#..#..#.....#...# +.....#.#.#........#....#...##.. +......#..#....#......#..##..... +............#......##.#....#..# +...#..........#..#...........#. +..........#.............###.... +....##.#.#......#.#..#....##..# +..#..........#........#......#. +..#...........####......##..#.# +...##......##...#..#.##........ +.....#...#.....##.....###..##.. +.#.##.....#....##....#......... +#....##..#.....#.#......#.#.... +..#.......#...#....#...#.#..... +...........#.........#......... +..#..#....##..#....#....#.....# +.......#..#....##....#......... +#.........#...........##....##. +#........#.#...............##.. +#...##.#...............#....... +#....#..#......#..#.###...##..# +..#.........#.#......#.....#..# +......#...........##........##. +.#.........#................#.. +#...#...............#...#....#. +.#.#......##.........#.#....... +..........#.................... +.#.....#..#...#.#.#.......#...# +..#..........#................. +.#.#.....#.#......#...#.....##. +.....#.#..##...##..#..###...#.. +......#......#.#......#.##..... +#.#......#...#.......#....#.... +..........#....#.#..#.....##... +#...........#.#....#.##....#.#. +#.#....#..#.........###....#... +..............#..##.......#.... +.......................#.##.#.. +##...............##....#..#.#.. +.#.#..#.##...#.............#... +...#...........#............#.. +..#......#........##....#.#.##. +.#.#..#........#....#....#....# +.#.....#.##....#.....#..#...#.. +......#...#..........#..###.... +..#.#.......#........#........# +.......##.####..........#...... +.#.#..#......##..#.........#..# +..#...##.#.......#...#.##...#.# +#.#..........#..#.#.#.......... +.....#......#............#..... +........###...#.......#........ +.....#.##....#....#............ +...#.#....##.....#.....#....... +..#.............#......#....... +.#....#...#....##..#......#.... +..#.....#.#............#....... +......#........##.........#...# +.......#........#..#.#.#...##.# +#....#...#..#.......#....##.... +#...##.#.#.....#.......#....... +.....#........#.#.....#...##... +..#....#..##......#.#.....#...# +....#.....#......#.....#....... +#.#....#......#...##........... +..#.......#...#...............# +........#........#............. +#.#.#......#...#..#..........#. +.##...#.........#........#..#.. +#.#.#...#.#.......#.....#...#.. +...#..............#..........#. +#.#...#.###.............#...... +................#.....###.##.#. +.......#..........#....#..#.... +......##....#..#..##........... +...#...#.....######.......#.... +..##.....##.#...#.........#.#.# +.......#...#..#.#.#...........# +........###.............#...#.# +#.....#.........#.............# +..#...#.....#.................. +.....#....#.....#......#.#....# +...#....#........##...#.......# +...##.#...#.....#.............. +..#.##....##..#.........#...... +.....#..#.#....#...#......#.#.. +...........##..##...#..#..###.. +#...........#.........####....# +.#...........#...........###... +........#................#..... +.....#....#............#....#.# +...#...#.......#............... +#.....##.#.......#.#........... +#.......#.#.#.#..#...#......... +....####.#...#.#......#.....##. +...##...#.....#.#......#..#.... +..........#..#....#......###... +...................#....##...#. +....#......#........#...##..#.. +##...#.........#.#......#...... +#........#...#....#......#..... +#..#.......#...............##.. +......##......#...........##.#. +......#..#....#....#.##........ +..#....#..#.#.###....#......... +.#......#..#..............#.... +.#..........#...#..#.#...#..... +....#......#..#......#....#.... +...##.....#............####..#. +......#.#...#....#..#...#..#.#. +......##....................... +#.##........#...........####..# +.....#......#.......#.#....#... +#.......#....#.....#....#...##. +.....#..##.#...........#..#...# +...........#.##.#.#...#.#..#... +..#.......#.#....#..#.......... +...#.......##..#.............#. +....#..#....#....#...#....#.... +#......#.#...##..........#..#.. +..#.#.......#.........#......#. +#...............#.............# +....##..#...................... +.##....#............#......#... +.......#....#..##......##...... +#..##.....#..#..........#...... +...#.........#.......#..##..... +....#.##.....#.#...#...#.....#. +##...........#.#..#...#.#...... +....#.............##...#.#..#.. +...#....#...................... +#..#...##.#.......#.##..#.###.. +...##.#.#...##........##...#... +......##..#..#.....#..#.#..#... +#.......##...............##.#.. +.##......#..#....#...##..#..#.# +##.........##..#...#.....##.... +...#..........#...#..##.#...... +..##.#........#...#..........## +.......................##.#.... +....#...#...#..###.#.......#.## +....#....#.#..........#.##..... +..#..........##...#....#....... +.....#.....#.....#..#.........# +..##..##..#..#....#..#.......## +.............#............##... +....#.#.#.......###.........#.. +...##.#..........#.#...#.#..... +.#........#..#.#.#..#.......... +...##...#.....##.......#..#..#. +...#......#..#.......##.#.#.... +.........#.........##........#. +.........##..................## +....##.....#................#.. +....#..................##...#.# +.........#..............#...... +...#......#..#..#....#..#...##. +.#.##......##...#.#......#.#... +...#.#...###....#...#.#..#....# +....#..#.......#.....#..##.#.#. +#.#.#..#.......#####.#..##..#.. +#..........#.....#..#.#..#..... +.#......#...#..#.#..#..#....... +...#....##...#..........#.##.#. +#.##..#...#..................#. +......#.###..#..#..#.......#... +...#....#...#..#............### +#.........#........#.......#... +...#..#.................#....## +...#.#.............##......#... +##....#.##.............##...... +#............#..#..#.....#..... +....#........#...#.....#.#...## +..#.##..#.....................# +#.#........#...#..#...#.#...... +...#..#...........##.....#..... +......#.#....#..##...#.....#... +......#......#.###..##......... +....#.......#...##.##.....#.... +#.....##....#........#..##..... +.#..#..#..#..#.#...#...#....... +.......##...#......#.........#. +.#..##....#.....#...........##. +.......##....#.#........#...... +..#.#.#....#................... +.#...#.......#...#.#......#.... +..##.##..##...........###...... +#...#......#.......#........... +#....##.#.......#.........#.... +.............##.#.#..#...#...#. +..##.##...........#.........##. +#.#...#..........#.#....#....## +.....#.....#..##..#............ +#.........#.........#.#...##..# +...#.#.....#.........###..#.... +..#.#.##.#...................#. +......####....#.......#.......# +.........#..#..#....#..##...... +....#..........#...##........#. +..........#..#....#.....#....#. +.#.#.................#....#.... +.......#......#.....#...##..... +....#..............#........... +###...........##.#...........#. +...####.......#...#....#.#...#. +..##.#................#........ +...#..#....#.....#.....##..#... +##.#....#....##..........#.#..# +...#....#.....#................ +..#...#....#..#..#.##.##..#.... +....#....#.##.....#...#......#. +......#................#..#..#. +...##..#...#....#.#.....#..#... +#...#..............#.#.....#.#. +....#.........#.##...#.#....#.. +..................#..##.#...... +.#.....#.....#.............#..# +..........####....###..##...#.. +......#........#...#......##..# +#......#.#..........#....#.#... +###................#.#....#.... +#..#.##.#.............#..#..... +.....#............#.....##..... +....#.....#....#.........#..... +#..#...........###.#....#...... +..#............##...#........## +..#....#..#....#.....#.......#. +..#..#.#.#.##.#..#...#.....#... +..........#..#................. +...#.#......#..##........#..... +...............#............... +#.......#.......#....#......... +#...........#....#............. +....#..#..........#....#..##... +.........#.#.#.........#......# +.....#...##.....#.#.......#...# +.........#....#...#.......#.... diff --git a/2020/3/sample_input b/2020/3/sample_input new file mode 100644 index 0000000..7e88cdc --- /dev/null +++ b/2020/3/sample_input @@ -0,0 +1,11 @@ +..##....... +#...#...#.. +.#....#..#. +..#.#...#.# +.#...##..#. +..#.##..... +.#.#.#....# +.#........# +#.##...#... +#...##....# +.#..#...#.# diff --git a/2020/3/solution.py b/2020/3/solution.py new file mode 100644 index 0000000..ce99481 --- /dev/null +++ b/2020/3/solution.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +fd = open("input", "r") +buf = [] +lines = fd.readlines() +lenlines = len(lines) + +for i in lines: + buf.append(i) + +def counter(l, c): + cnt = 0 + for i in l: + if i == c: cnt += 1 + return cnt + +def listmapper(l, x, y): + hlen = len(l[0]) - 1 + return l[y][x % hlen] + print(x % hlen) + +def getTrees(x, y): + try: + pos = (0, 0) + cnt = 0 + while True: + pos = (pos[0] + x, pos[1] + y) + if listmapper(buf, pos[0], pos[1]) == '#': cnt += 1 + except IndexError: + pass + return cnt + +print(getTrees(3, 1)) +print("--") + +cnt = 1 +for i in [[1, 1], [3, 1], [5, 1], [7, 1], [1, 2]]: + trees = getTrees(i[0], i[1]) + cnt *= trees + print("{}, {} -- {} ({})".format(i[0], i[1], trees, cnt))