mebeim / aoc

🎄 My solutions and walkthroughs for Advent of Code and more related stuff.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typo in y2023 d16 walkthrough

ismagilli opened this issue · comments

First version of travel function in walkthrough looks follows:

...

while 1:
    # Are we out of bounds?
    if 0 <= r < height and 0 <= c < width:
        # Can't possibly continue!
        break

    # Dif we already get here while also going in the same direction?
    if (r, c, dr, dc) not in seen:
        # This is a loop!
        break

    ...

But these conditions must be inverted:

 while 1:
     # Are we out of bounds?
-    if 0 <= r < height and 0 <= c < width:
+    if not (0 <= r < height and 0 <= c < width):
         # Can't possibly continue!
         break

     # Dif we already get here while also going in the same direction?
-    if (r, c, dr, dc) not in seen:
+    if (r, c, dr, dc) in seen:
         # This is a loop!
         break

Thank you for spotting the typos! Fixed in d41d8d1.