diff --git a/2020/03/.inputShort.txt.swp b/2020/03/.inputShort.txt.swp new file mode 100644 index 0000000..e5d3e1d Binary files /dev/null and b/2020/03/.inputShort.txt.swp differ diff --git a/2020/03/03.py b/2020/03/03.py new file mode 100755 index 0000000..98c5daa --- /dev/null +++ b/2020/03/03.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 + +# Advent Of Code 2020 - Day 3 + +""" +...#.#..#..#..#..............## +.##.......###.#......#....#..## +..##.##.#......#....#..#...#..# + + +..##....... +""" + +filename = "input.txt" + +with open(filename) as f: + content = f.readlines() + +trees = 0 + +totalRows = len(content)-1 +totalColumns = len(content[0])-1 + +#print (totalColumns) +#print (totalRows) + + +x,y = 0,0 +moveRight = 3 +moveDown = 1 + +row = 0 + +while row < totalRows: + + x = x + moveDown + y = y + moveRight + + + if y >= totalColumns: + y = y - totalColumns +# print (y) + +# print (x, y) + if content[x][y] == "#": + trees = trees + 1 + + row = row +1 + +print (trees) + +""" +0,0 +right 3, down 1 ++3,+1 + +check if y is >= len(content) + print trees result + +check if x is >= len(line) + move to start of the line and continue + +""" diff --git a/2020/03/03b.py b/2020/03/03b.py new file mode 100755 index 0000000..86a4a4a --- /dev/null +++ b/2020/03/03b.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +# Advent Of Code 2020 - Day 3 + +""" +...#.#..#..#..#..............## +.##.......###.#......#....#..## +..##.##.#......#....#..#...#..# + + +..##....... + +Right 1, down 1. +Right 3, down 1. (This is the slope you already checked.) +Right 5, down 1. +Right 7, down 1. +Right 1, down 2. + +multiply all runs + + +""" +#[right,down] +runs = [[1,1], + [3,1], + [5,1], + [7,1], + [1,2]] + + + +filename = "input.txt" + +with open(filename) as f: + content = f.readlines() + +treesTotal = 1 + +totalRows = len(content)-1 +totalColumns = len(content[0])-1 + +print (totalColumns) +print (totalRows) + +for run in runs: + + x,y = 0,0 + moveRight = run[0] + moveDown = run[1] + trees = 0 + + row = 0 + + while x < totalRows: + + x = x + moveDown + y = y + moveRight + + # didn't bother changing the while loop, so here we check if we are over the end + if x > totalRows: + break + + if y >= totalColumns: + y = y - totalColumns + + if content[x][y] == "#": + trees = trees + 1 + + row = row +1 + + treesTotal = trees * treesTotal + + +print (treesTotal) diff --git a/2020/03/input.txt b/2020/03/input.txt new file mode 100644 index 0000000..02364e0 --- /dev/null +++ b/2020/03/input.txt @@ -0,0 +1,323 @@ +.##.............##......#.....# +.#.#................#.......... +...#..#.##..#.#......#.#.#.#..# +..#......#........#..#..#.#.#.. +.......#....#..#..#.......#.... +..#..#..##.#...#........#.###.. +..#...#..#.....#.##....#....... +....#..###.#......#.##..#...##. +..#..........#.##.#...#........ +#...#............##....#..##... +.......##....#.....##..#.#..#.# +..#..#..#...#....#....#....#... +.#...#.##........#####........# +..#..#......#.....##...#....... +....#......##....#.#....#.#..## +#.#.##....##..#.........#.###.. +##..###..#..#.......###.......# +...#.#......#.........#....#... +.....#..........#.....##..#.#.. +....##......#.#..#....#.#...... +..#.....#..##.......##......#.. +.........##.##.#..##........... +....#...#.....#....#.#.###....# +.##.#..#...##..#.......#......# +##..#..#..####..#.#..#...#..... +..###..#..#..#.###..#....#.##.. +......#...###.#.#.....#........ +.....#...#.#...#.......#.....#. +#........#..##...........#..#.. +.#.##.##...#.....#.#....#..#... +..##.##....#.....#....#....##.. +#.........##...##..#.....#..#.. +........#.####....#...##.....#. +.#.#...#..#..#.#......##.....#. +..#..........##..#.#.#....#...# +#.......#...#...#.....#.##.#... +..#.....#..#.....####.#..#.#.## +...#.#..#...#.....#...#.#.#.#.# +.#..##....##.....#..#....###... +....#......##.#.#.....#......#. +..#.#...#......#.....##.......# +..#...###...#..#.#...#..#.....# +#..............#.....#....##..# +.#...#.......#.............#... +..###....#.##........#.#....... +#.##.......#..#............###. +#...#..##.#.#............###### +..##..#....#.#.###...#..##.##.. +.#...#.###.#....#...#....#...#. +#...#.......#...........#...##. +##.#......#####.............#.. +....#..#......##..#..........#. +#.....#.....#.#.......#...#...# +....#...#.#..##........#.#..##. +..##.....##............#.#.###. +#.........#........#..###...... +............#.................. +.#.###...####...#.#..#......#.. +...##.###.#....##.#..####..#.## +..#####.#.##...#.#...##.##....# +........##...#...#....##.....## +#...........###...#.#...##.#... +##......#...#.......###........ +..#..#.##.#..###....#..#.###.#. +...#.#.#...#....#.##..#...#.... +........#.##...##.#.....##...## +.#..........##..#..#..#.#...#.. +#.#...#.##.#....#.##..#........ +.#.#.#....##..##.####.....###.. +..#....##....#..#..#..##....... +..##...#.......#...##.#....#... +...####.#.#...........#.#...#.. +....####.....#.#.....#....##.## +..#.....#.#.............##....# +#.#....#####.##..####.#...#.#.. +#.#....#.##.#.#.##..#.#...#.... +......#.......#.......#.....#.. +..#.....#....###.###..#..#..#.. +#..#....##.###...##.....#...... +..#..#...#..#.##..........#.... +...#.#.#......#....#.##..#..##. +....##.#....#..#...##....###... +##.#.###.....#..#.#.#..#.....## +##..#.#........#...#..#.#...... +....#.#.......##.#...........#. +.......##...#...#...#.....#.... +.....#....#..#..###.#...#...... +............#.#..#......#.#.... +...##..#.##....##..##.#......#. +#.#.#......#.#.....#.#.#..#.#.# +...###..........#..#..#.##..... +......#......#......###..##.... +#...##...#....#....#..#...#.#.. +.......#..#......##.......#.... +...#..#..#.....#.....#......##. +..#....###..........##..#...#.. +..........#..#.#...#......#..#. +#...#....#.##.........#.#.#...# +.#.#.#...#.#...#.#..#..#....#.# +#.##....#..#.........#.##.##..# +..#.#..##.#....#.###.#...#....# +.#.......#...#.#.........#....# +.......#...#..........#.#..#... +...#.....##..#....#...###...#.# +#....##.##..........#.......#.. +.##..##......#...#....#.##....# +....#.....##...##.#..#......... +...#.#..##.#.#..#.......#....#. +.#...#.#.#.#..#..#.##.......#.. +..#..##...#.#..#.......#.#####. +.......#.#...........#....#.#.. +.#.###..........#...#..#...#... +..#.#............##......##.... +...##..#...###...##....#.#.##.. +....#.##...#..#.#.#...........# +....#..#....##.....#.##.#.....# +..##......##.#.........#....#.# +###...#...#..#.#...#........... +.####.....#.....#.#....#..#.... +.#....#..#..#..#...##.....###.# +#....##.#....#.##..#......##..# +.........#..#.#.....#.#....##.# +.....#.#...#....#.#...#....#..# +.#...#.#.....#.#......#.#...... +#....##.......#.............#.. +#..#...#........##..#..#......# +####..##.#..##..#.........####. +.#.##..#.#..#.#.#.##...#..#.#.# +.##.#..#............#......#... +###....#.##....#..#...#........ +.....#..###..........#..#...... +.##..##.....#..##....#...#..... +#...##...........#..#...###..#. +#..##....#...#.##.##....#...... +...#...#..#.#.......##.......## +....#.....#..#...#.........#.#. +.#...##.#......#.#..#..#...##.. +...##...##.##...##...#..#...... +#..##.#..#..#............#...#. +..#.....#.........#........#.#. +#.#...#...#......#.#......#.... +.##.....##.#.#....#.##...##.#.. +.##..##.#.#....#.##............ +.#.##.....##.#...#...###....#.. +.#..............#.#....###.###. +....#..#...#.#.#..........#.#.# +.#.#..#.#.#...###..#...##...... +.#.#.....###......#..........#. +........#.##...............#.#. +...#.#.#......#..#..##........# +..#.##......#.......#..#......# +...#...#...#...#..#..#........# +..#....#.....#....#..##........ +.....#..#...##....#......##.... +...##..##..#..........##....#.# +..#....#..#...#.##..#.....##... +###...#.#....#........#.......# +......#...#..#....###.........# +..###.#...#...#...#.#..###.#... +.##.#.......#.#..#..#......#.#. +...##...........#.#..#.#..#.... +.......#.....####.#.....#...#.# +......##......##.#.#.#...#.#..# +..###.#####..#....#.#...#..##.. +.....#..#......#........#...... +#..##....#.#.##....#....#...... +.#....#.##.####.##..#..#......# +#...##...#.#...##.#.##.##...#.. +........#.#........#.#...#..#.. +.#....###..#......#.##.###..#.. +.#..#..#..#..#...#.#.........## +....#...#..#..............#.... +........#...##.....#.......#... +..#......#.#..#.#..#.#.#...###. +....#...####....###....#......# +#...#.#...................#.##. +..#.#.###...#....##....##...... +#..##..#.........#....#....#### +.#....###...#.#...#......#...#. +......#..#.#..#.##...#.#.#..#.. +.#...#.#.....#..##......#..#... +##.#..##.....##.#.#.......##... +.##.##.##..#...#.#.##.##....... +.#.#......#.....#...#.#..#..... +...#...........#..#.##..##..#.. +.....#...##......#........#.#.. +....#..............##.........# +..####.#....##..##......##.#.#. +.#.#..#...#..........#...###..# +....#.#.##.....###.#..#.##..... +.......##.#.#..#...#...##.#.... +...#.##.....#....#...#...#..... +##.#.##..#..#.#.....#.#..#..... +..#..##........#....###..#..#.. +..#.........##.....#......#...# +...##..........##......#.#.#... +#.....#..#..#......#......#.... +.##...#..##....#.......##..#.#. +.#...##...##......####.##.#.... +.....#.........#.#.####......#. +...#.....#.#.........##..#..... +##.#.###.#..#.#..#............# +...##..#.#....#....#..#........ +..#.###......#...#.#.....#...#. +....##.##..#.....#...#.#.#....# +.......#.#..#...........#.#.... +.#.#..##.#.......#.#..#.....### +...#.#.....#.#..#.##..#...#.#.. +...#......##....#.............. +......#...#.................... +..#........#...##.##.#..#.#.#.. +.#.###.#.##..##..#....##....#.. +.....#..#.#...#.#..#..#.......# +..........#.##.#..##..####..... +............#.#......#......... +.#....#..#......#.....##....... +.....#........#.....##.#..#.#.. +#..#.##...#.#.....#...#.####... +......#...#....#.##..##.#...#.. +.#.#.##......##....#.#....#.##. +#.#.#....#.###....##....##..... +.##..#...#.##......#..#..#...## +...#....###....#...........#.#. +#.#.##.##...##....#....##.#...# +.#.#######.......#......#...... +#......#...#.#.#.###....#.##..# +......##..#..##.........##.#.## +....##...#.#....##.....#.....#. +..#.#........##........#.#..##. +.....#..#.##.....#.....#..#.#.. +.#..............#.......#...... +.............#..#..........#... +.#..#.##....##.#..#...##....... +...........#..#.......#.#....#. +.#..#..........##...#.#.#...#.. +......#....#..###....#......#.. +.#...#...##..#..#..##..#..#.#.. +#.#.........#....#..........##. +...##..#..##...#....##...##.##. +..#....#.####.........#.....##. +.....#.#...#.#...#.##.#...##..# +#...#.....#..#.......#...#..#.. +..#.......#..##.#.....#....#... +.#.....#..##.#.....#...#.#...#. +.....#.##..........##....#...#. +...#....#...#........##...#...# +....##...#....#..........#..... +...#....##..#..####..##.#...#.# +#...###.###..#....##.#......... +.#.......#......#.........#.... +..#..##..#.........##.......... +#......#.#.##...#...#####...... +......#.....####......#....#... +.........#..#..#...#....#.#.... +....#........#...##....#....... +...##.#...#..........#....#.... +........#.......#.##..#..#...#. +....#..##...........#.....#..#. +#....#...............#.#....#.. +.#........#....#.#...#.......#. +#.......##..........#.......#.. +...#....#...##.#..#.......#.... +#..#.##...#.#...#...#...#....#. +###...#...#....#....#....#...#. +##......#.#.......#....#..#.... +......#......#....#.#.#..###..# +.#.#.##.....#..#..........#.... +##...#.#.#..##....#.....#.#.... +#.##...#...#.#...####..#....... +.....##..#.#.#....#..##..#.#... +....###.#.........##.....#..... +......##...........#........#.# +.#.........##.................. +.........##...#.............#.# +......##...#...#.........#..##. +#..#.......#..##.......###..... +....#.#.....#............##.... +.....#..#......#....#.....##... +##......##...................#. +#....#............#.#.###.##... +.#.....#........#.....#...#.... +......##.......######......##.. +.#....##....#..###....#.......# +..............##.#..#.......#.# +.#..#..........#..#.##......... +......##.#..#......#.#....##.#. +#.....#.##...#.....#...#..#...# +.#....#..##.....#.....#.#.#.... +..#......#.##..#.........#.#.#. +.#..##...#...#.....#..#..#.#..# +#.#.##.##.................#.#.# +.#..#.#..##.#.......#.......##. +#...#...#..##...#...##...#...#. +....#......#..#...#.....##..#.. +..............##......#...#.#.. +..##..#.......#..#..###.#.#.... +.#..#..#...#.......#...#...##.# +.#...#.......###..#.##.###..... +##.#...#......#.....#..#....... +##....##............#.....#..#. +.....#...##......##.....#....## +#...##..#....#..##....###.#...# +.....#..#.#.....#.##..##....#.. +.#.....#.#........#...#.#...... +......#....#.#........#.#...... +.##..#...............###...##.# +.......###.#.#......###.....#.. +.......#..##...#....#.##..#.##. +..#.......##.......#.....#....# +.#......#....#..##..#.#.#..##.. +###......#...#..#.............# +.#....#..#.#......##........... +.#....#.##.....#..#.......#..## +....#...#...#..#.....#..##..#.# +#.#.#.......##.#..#.#....#..... +##.#.......#...#...#.#......##. +#....#.#...........#######..... +...#.#.##.#......##..###....... +..#.#....#..#.................# +........#..##..#.....#....#.##. +...#.#..#..#..#..............## +.##.......###.#......#....#..## +..##.##.#......#....#..#...#..# diff --git a/2020/03/inputShort.txt b/2020/03/inputShort.txt new file mode 100644 index 0000000..7e88cdc --- /dev/null +++ b/2020/03/inputShort.txt @@ -0,0 +1,11 @@ +..##....... +#...#...#.. +.#....#..#. +..#.#...#.# +.#...##..#. +..#.##..... +.#.#.#....# +.#........# +#.##...#... +#...##....# +.#..#...#.#