better (and faster) solution
This commit is contained in:
parent
fcd394aaba
commit
a3d2b5140f
16
day03.py
Normal file → Executable file
16
day03.py
Normal file → Executable file
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user