X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2020.git/blobdiff_plain/a2ce7bb47964e226d4b10b791a038ca1f1fa67d7..fe0197cb1dc8f701b69ce52b9acb445351557c8d:/day03/count_trees_2.py diff --git a/day03/count_trees_2.py b/day03/count_trees_2.py new file mode 100644 index 0000000..84a3883 --- /dev/null +++ b/day03/count_trees_2.py @@ -0,0 +1,36 @@ +#!/usr/bin/python3 + +trees_count = [] +on_first_line = True +line_number = 0 + +move_types = ((1,1), (3,1), (5,1), (7,1), (1,2)) + +for move in move_types: + line_offset = 0 + tree_count = 0 + position = move[0] + first_line = True + for line in open("input.txt", "r"): + line = line.rstrip() + print(move[1], line_offset) + if line_offset < move[1] or first_line: + line_offset += 1 + if line_offset >= move[1]: + first_line = False + continue + line_offset = 1 + if line[position] == "#": + tree_count += 1 + position += move[0] + if position >= len(line): + position = position - len(line) + trees_count.append(tree_count) + tree_count = 0 + +mult_result = 1 +for x in trees_count: + print(x) + mult_result *= x + +print("There were", mult_result, "trees")