This commit is contained in:
Deni 2020-12-03 09:00:00 +01:00
parent bee9432ebe
commit 84559867ff
5 changed files with 471 additions and 0 deletions

BIN
2020/03/.inputShort.txt.swp Normal file

Binary file not shown.

63
2020/03/03.py Executable file
View File

@ -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
"""

74
2020/03/03b.py Executable file
View File

@ -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)

323
2020/03/input.txt Normal file
View File

@ -0,0 +1,323 @@
.##.............##......#.....#
.#.#................#..........
...#..#.##..#.#......#.#.#.#..#
..#......#........#..#..#.#.#..
.......#....#..#..#.......#....
..#..#..##.#...#........#.###..
..#...#..#.....#.##....#.......
....#..###.#......#.##..#...##.
..#..........#.##.#...#........
#...#............##....#..##...
.......##....#.....##..#.#..#.#
..#..#..#...#....#....#....#...
.#...#.##........#####........#
..#..#......#.....##...#.......
....#......##....#.#....#.#..##
#.#.##....##..#.........#.###..
##..###..#..#.......###.......#
...#.#......#.........#....#...
.....#..........#.....##..#.#..
....##......#.#..#....#.#......
..#.....#..##.......##......#..
.........##.##.#..##...........
....#...#.....#....#.#.###....#
.##.#..#...##..#.......#......#
##..#..#..####..#.#..#...#.....
..###..#..#..#.###..#....#.##..
......#...###.#.#.....#........
.....#...#.#...#.......#.....#.
#........#..##...........#..#..
.#.##.##...#.....#.#....#..#...
..##.##....#.....#....#....##..
#.........##...##..#.....#..#..
........#.####....#...##.....#.
.#.#...#..#..#.#......##.....#.
..#..........##..#.#.#....#...#
#.......#...#...#.....#.##.#...
..#.....#..#.....####.#..#.#.##
...#.#..#...#.....#...#.#.#.#.#
.#..##....##.....#..#....###...
....#......##.#.#.....#......#.
..#.#...#......#.....##.......#
..#...###...#..#.#...#..#.....#
#..............#.....#....##..#
.#...#.......#.............#...
..###....#.##........#.#.......
#.##.......#..#............###.
#...#..##.#.#............######
..##..#....#.#.###...#..##.##..
.#...#.###.#....#...#....#...#.
#...#.......#...........#...##.
##.#......#####.............#..
....#..#......##..#..........#.
#.....#.....#.#.......#...#...#
....#...#.#..##........#.#..##.
..##.....##............#.#.###.
#.........#........#..###......
............#..................
.#.###...####...#.#..#......#..
...##.###.#....##.#..####..#.##
..#####.#.##...#.#...##.##....#
........##...#...#....##.....##
#...........###...#.#...##.#...
##......#...#.......###........
..#..#.##.#..###....#..#.###.#.
...#.#.#...#....#.##..#...#....
........#.##...##.#.....##...##
.#..........##..#..#..#.#...#..
#.#...#.##.#....#.##..#........
.#.#.#....##..##.####.....###..
..#....##....#..#..#..##.......
..##...#.......#...##.#....#...
...####.#.#...........#.#...#..
....####.....#.#.....#....##.##
..#.....#.#.............##....#
#.#....#####.##..####.#...#.#..
#.#....#.##.#.#.##..#.#...#....
......#.......#.......#.....#..
..#.....#....###.###..#..#..#..
#..#....##.###...##.....#......
..#..#...#..#.##..........#....
...#.#.#......#....#.##..#..##.
....##.#....#..#...##....###...
##.#.###.....#..#.#.#..#.....##
##..#.#........#...#..#.#......
....#.#.......##.#...........#.
.......##...#...#...#.....#....
.....#....#..#..###.#...#......
............#.#..#......#.#....
...##..#.##....##..##.#......#.
#.#.#......#.#.....#.#.#..#.#.#
...###..........#..#..#.##.....
......#......#......###..##....
#...##...#....#....#..#...#.#..
.......#..#......##.......#....
...#..#..#.....#.....#......##.
..#....###..........##..#...#..
..........#..#.#...#......#..#.
#...#....#.##.........#.#.#...#
.#.#.#...#.#...#.#..#..#....#.#
#.##....#..#.........#.##.##..#
..#.#..##.#....#.###.#...#....#
.#.......#...#.#.........#....#
.......#...#..........#.#..#...
...#.....##..#....#...###...#.#
#....##.##..........#.......#..
.##..##......#...#....#.##....#
....#.....##...##.#..#.........
...#.#..##.#.#..#.......#....#.
.#...#.#.#.#..#..#.##.......#..
..#..##...#.#..#.......#.#####.
.......#.#...........#....#.#..
.#.###..........#...#..#...#...
..#.#............##......##....
...##..#...###...##....#.#.##..
....#.##...#..#.#.#...........#
....#..#....##.....#.##.#.....#
..##......##.#.........#....#.#
###...#...#..#.#...#...........
.####.....#.....#.#....#..#....
.#....#..#..#..#...##.....###.#
#....##.#....#.##..#......##..#
.........#..#.#.....#.#....##.#
.....#.#...#....#.#...#....#..#
.#...#.#.....#.#......#.#......
#....##.......#.............#..
#..#...#........##..#..#......#
####..##.#..##..#.........####.
.#.##..#.#..#.#.#.##...#..#.#.#
.##.#..#............#......#...
###....#.##....#..#...#........
.....#..###..........#..#......
.##..##.....#..##....#...#.....
#...##...........#..#...###..#.
#..##....#...#.##.##....#......
...#...#..#.#.......##.......##
....#.....#..#...#.........#.#.
.#...##.#......#.#..#..#...##..
...##...##.##...##...#..#......
#..##.#..#..#............#...#.
..#.....#.........#........#.#.
#.#...#...#......#.#......#....
.##.....##.#.#....#.##...##.#..
.##..##.#.#....#.##............
.#.##.....##.#...#...###....#..
.#..............#.#....###.###.
....#..#...#.#.#..........#.#.#
.#.#..#.#.#...###..#...##......
.#.#.....###......#..........#.
........#.##...............#.#.
...#.#.#......#..#..##........#
..#.##......#.......#..#......#
...#...#...#...#..#..#........#
..#....#.....#....#..##........
.....#..#...##....#......##....
...##..##..#..........##....#.#
..#....#..#...#.##..#.....##...
###...#.#....#........#.......#
......#...#..#....###.........#
..###.#...#...#...#.#..###.#...
.##.#.......#.#..#..#......#.#.
...##...........#.#..#.#..#....
.......#.....####.#.....#...#.#
......##......##.#.#.#...#.#..#
..###.#####..#....#.#...#..##..
.....#..#......#........#......
#..##....#.#.##....#....#......
.#....#.##.####.##..#..#......#
#...##...#.#...##.#.##.##...#..
........#.#........#.#...#..#..
.#....###..#......#.##.###..#..
.#..#..#..#..#...#.#.........##
....#...#..#..............#....
........#...##.....#.......#...
..#......#.#..#.#..#.#.#...###.
....#...####....###....#......#
#...#.#...................#.##.
..#.#.###...#....##....##......
#..##..#.........#....#....####
.#....###...#.#...#......#...#.
......#..#.#..#.##...#.#.#..#..
.#...#.#.....#..##......#..#...
##.#..##.....##.#.#.......##...
.##.##.##..#...#.#.##.##.......
.#.#......#.....#...#.#..#.....
...#...........#..#.##..##..#..
.....#...##......#........#.#..
....#..............##.........#
..####.#....##..##......##.#.#.
.#.#..#...#..........#...###..#
....#.#.##.....###.#..#.##.....
.......##.#.#..#...#...##.#....
...#.##.....#....#...#...#.....
##.#.##..#..#.#.....#.#..#.....
..#..##........#....###..#..#..
..#.........##.....#......#...#
...##..........##......#.#.#...
#.....#..#..#......#......#....
.##...#..##....#.......##..#.#.
.#...##...##......####.##.#....
.....#.........#.#.####......#.
...#.....#.#.........##..#.....
##.#.###.#..#.#..#............#
...##..#.#....#....#..#........
..#.###......#...#.#.....#...#.
....##.##..#.....#...#.#.#....#
.......#.#..#...........#.#....
.#.#..##.#.......#.#..#.....###
...#.#.....#.#..#.##..#...#.#..
...#......##....#..............
......#...#....................
..#........#...##.##.#..#.#.#..
.#.###.#.##..##..#....##....#..
.....#..#.#...#.#..#..#.......#
..........#.##.#..##..####.....
............#.#......#.........
.#....#..#......#.....##.......
.....#........#.....##.#..#.#..
#..#.##...#.#.....#...#.####...
......#...#....#.##..##.#...#..
.#.#.##......##....#.#....#.##.
#.#.#....#.###....##....##.....
.##..#...#.##......#..#..#...##
...#....###....#...........#.#.
#.#.##.##...##....#....##.#...#
.#.#######.......#......#......
#......#...#.#.#.###....#.##..#
......##..#..##.........##.#.##
....##...#.#....##.....#.....#.
..#.#........##........#.#..##.
.....#..#.##.....#.....#..#.#..
.#..............#.......#......
.............#..#..........#...
.#..#.##....##.#..#...##.......
...........#..#.......#.#....#.
.#..#..........##...#.#.#...#..
......#....#..###....#......#..
.#...#...##..#..#..##..#..#.#..
#.#.........#....#..........##.
...##..#..##...#....##...##.##.
..#....#.####.........#.....##.
.....#.#...#.#...#.##.#...##..#
#...#.....#..#.......#...#..#..
..#.......#..##.#.....#....#...
.#.....#..##.#.....#...#.#...#.
.....#.##..........##....#...#.
...#....#...#........##...#...#
....##...#....#..........#.....
...#....##..#..####..##.#...#.#
#...###.###..#....##.#.........
.#.......#......#.........#....
..#..##..#.........##..........
#......#.#.##...#...#####......
......#.....####......#....#...
.........#..#..#...#....#.#....
....#........#...##....#.......
...##.#...#..........#....#....
........#.......#.##..#..#...#.
....#..##...........#.....#..#.
#....#...............#.#....#..
.#........#....#.#...#.......#.
#.......##..........#.......#..
...#....#...##.#..#.......#....
#..#.##...#.#...#...#...#....#.
###...#...#....#....#....#...#.
##......#.#.......#....#..#....
......#......#....#.#.#..###..#
.#.#.##.....#..#..........#....
##...#.#.#..##....#.....#.#....
#.##...#...#.#...####..#.......
.....##..#.#.#....#..##..#.#...
....###.#.........##.....#.....
......##...........#........#.#
.#.........##..................
.........##...#.............#.#
......##...#...#.........#..##.
#..#.......#..##.......###.....
....#.#.....#............##....
.....#..#......#....#.....##...
##......##...................#.
#....#............#.#.###.##...
.#.....#........#.....#...#....
......##.......######......##..
.#....##....#..###....#.......#
..............##.#..#.......#.#
.#..#..........#..#.##.........
......##.#..#......#.#....##.#.
#.....#.##...#.....#...#..#...#
.#....#..##.....#.....#.#.#....
..#......#.##..#.........#.#.#.
.#..##...#...#.....#..#..#.#..#
#.#.##.##.................#.#.#
.#..#.#..##.#.......#.......##.
#...#...#..##...#...##...#...#.
....#......#..#...#.....##..#..
..............##......#...#.#..
..##..#.......#..#..###.#.#....
.#..#..#...#.......#...#...##.#
.#...#.......###..#.##.###.....
##.#...#......#.....#..#.......
##....##............#.....#..#.
.....#...##......##.....#....##
#...##..#....#..##....###.#...#
.....#..#.#.....#.##..##....#..
.#.....#.#........#...#.#......
......#....#.#........#.#......
.##..#...............###...##.#
.......###.#.#......###.....#..
.......#..##...#....#.##..#.##.
..#.......##.......#.....#....#
.#......#....#..##..#.#.#..##..
###......#...#..#.............#
.#....#..#.#......##...........
.#....#.##.....#..#.......#..##
....#...#...#..#.....#..##..#.#
#.#.#.......##.#..#.#....#.....
##.#.......#...#...#.#......##.
#....#.#...........#######.....
...#.#.##.#......##..###.......
..#.#....#..#.................#
........#..##..#.....#....#.##.
...#.#..#..#..#..............##
.##.......###.#......#....#..##
..##.##.#......#....#..#...#..#

11
2020/03/inputShort.txt Normal file
View File

@ -0,0 +1,11 @@
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#