diff --git a/day03.py b/day03.py old mode 100644 new mode 100755 index 4b8bd99..78a6344 --- a/day03.py +++ b/day03.py @@ -8,19 +8,13 @@ def check_for_trees(right_step, down_step, treelines): x = 0 y = 0 tree_count = 0 - for treeline in treelines: - if y % down_step != 0: - y = y + 1 - continue - - while len(treeline) < x + 1: - treeline = treeline + treeline - - if treeline[x] == '#': + maxX = len(treelines[0]) + while y < len(treelines): + if treelines[y][x] == '#': tree_count = tree_count + 1 - x = x + right_step - y = y + 1 + y = y + down_step + x = (x + right_step) % maxX return tree_count