]> git.sommitrealweird.co.uk Git - advent-of-code-2020.git/blob - day03/count_trees_2.py
Day 8 2020
[advent-of-code-2020.git] / day03 / count_trees_2.py
1 #!/usr/bin/python3
2
3 trees_count = []
4 on_first_line = True
5 line_number = 0
6
7 move_types = ((1,1), (3,1), (5,1), (7,1), (1,2))
8
9 for move in move_types:
10     line_offset = 0
11     tree_count = 0
12     position = move[0]
13     first_line = True
14     for line in open("input.txt", "r"):
15         line = line.rstrip()
16         print(move[1], line_offset)
17         if line_offset < move[1] or first_line:
18             line_offset += 1
19             if line_offset >= move[1]:
20                 first_line = False
21             continue
22         line_offset = 1
23         if line[position] == "#":
24             tree_count += 1
25         position += move[0]
26         if position >= len(line):
27             position = position - len(line)
28     trees_count.append(tree_count)
29     tree_count = 0
30
31 mult_result = 1
32 for x in trees_count:
33     print(x)
34     mult_result *= x
35
36 print("There were", mult_result, "trees")