Last test of second part tripped me up because I had 'y' incrementing by 1 each step, rather than 'dy'. Took me bloody ages to figure that out, not as bad as not reading the bloody question yesterday though.
https://github.com/lewfowls/AoC2020/blob/main/Day3code.py
yeah similar here, was filtering to get dy lines after moving down 1 rather than moving down dy lines and then counting...
Very C-like, I ended up writing
def trees(grid, r, d): return sum(row[(i*r) % len(row)] == "#" for i, row in enumerate(grid[::d]))
for the find-trees function.
@lf started
London Fixed Gear and Single-Speed is a community of predominantly fixed gear and single-speed cyclists in and around London, UK.
This site is supported almost exclusively by donations. Please consider donating a small amount regularly.
Last test of second part tripped me up because I had 'y' incrementing by 1 each step, rather than 'dy'.
Took me bloody ages to figure that out, not as bad as not reading the bloody question yesterday though.
https://github.com/lewfowls/AoC2020/blob/main/Day3code.py