Skip to content

Instantly share code, notes, and snippets.

@switowski
Created January 29, 2021 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save switowski/04cad4a277d26e831d6a2ae1a90f9ab4 to your computer and use it in GitHub Desktop.
Save switowski/04cad4a277d26e831d6a2ae1a90f9ab4 to your computer and use it in GitHub Desktop.
In [5]: %xmode
Exception reporting mode: Context
In [6]: solve()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-8-6f300b4f5987> in <module>
----> 1 solve()
~/workspace/iac/solver.py in solve()
25 def solve():
26 vals = getInput()
---> 27 sol_part1 = part1(vals)
28 print(f"Part 1: {sol_part1}")
29 print(f"Part 2: {part2(vals, sol_part1)}")
~/workspace/iac/solver.py in part1(vals)
14
15 def part1(vals: list) -> int:
---> 16 return count_trees(vals, 3, 1)
17
18 def part2(vals: list, sol_part1: int) -> int:
~/workspace/iac/solver.py in count_trees(vals, dx, dy)
9 x = (x + dx) % mod
10 y += dy
---> 11 if vals[y][x] == "#":
12 cnt += 1
13 return cnt
IndexError: list index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment