Unable to load image

rDrama Advent of Code Day 10: Pipe ( | ) edition

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

15
Jump in the discussion.

No email address required.

My part 1 was broken and couldn't figure it out, so i copy pasted like 10 solutions from the reddit solution thread that all gave me a wrong solution. And eventually I found the issue myself.

At the end the issue was that my F, moved exactly like the L. Otherwise it is just a simple dfs(and hoping that the longest contiguous part is the loop. But it would be easy to check if you reached S again. Also surrounded my entire pipe maze with one '.' in every direction, to not have to do bounds checking.

https://i.rdrama.net/images/17022025516693356.webp

Part 2, whenever I find time later

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17022166884442434.webp

Okay here is part 2. The only issue right now is that I have manually replace the 'S' with the appropriate symbol for part 2.

Actually was not that hard, but struggled a bit getting the logic of the raycasting right.

Basically to find out if a point is inside the loop polygon, you need traverse the row up to that point and count how many pipes were traversed.

| counts as one pipe break

L followed by a 7 counts as one break (ofc consider any amount of - inbetween)

F followed by J counts as one break

F followed by 7 and L followed by J don't count.

The point is then in the polygon if breaks % 2 == 1.

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.