day4 so far + formatz

This commit is contained in:
2020-12-06 23:06:44 +01:00
parent 4d05cc0bb9
commit d9c12bc074
6 changed files with 1249 additions and 18 deletions

View File

@@ -1,10 +1,12 @@
lines = []
def load():
global lines
file = open("day3/input.txt")
lines = file.readlines()
def trees(right, down):
width = 0
height = 0
@@ -13,21 +15,24 @@ def trees(right, down):
while height < len(lines):
line = lines[height]
if(line[width % line_width] == "#"):
if (line[width % line_width] == "#"):
count += 1
width += right
height += down
return count
def part1():
print("Part 1: %d"% trees(3,1))
print("Part 1: %d" % trees(3, 1))
def part2():
count = trees(1,1) * trees(3,1) * trees(5,1) * trees(7,1) * trees(1,2)
count = trees(1, 1) * trees(3, 1) * trees(5, 1) * trees(7, 1) * trees(1, 2)
print("Part 2: %d" % count)
if __name__ == "__main__":
load()
part1()
part2()
part2()