Unable to load image

rDrama Advent of Code Day 18: Network Engineering 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)

36
Jump in the discussion.

No email address required.

https://files.catbox.moe/fhyl9h.jpg

https://files.catbox.moe/btjujo.jpg

my best result ever, shoutout to whoever mentioned point in polygon a couple days ago, I just import solution'd and it runs instantly. I didn't even figure out why the area calculation was off until after I finished, I just subtracted my calculated area from the provided example's correct answer, and saw that it was about half the perimeter's length. For p1 I didn't even figure that out, I iterated across every integer coordinate in the bounding rectangle and summed whether they were inside the polygon, then added that to the perimeter length lmfao

there's still hope, fellow brainlets

Jump in the discussion.

No email address required.

>I iterated across every integer coordinate in the bounding rectangle and summed whether they were inside the polygon

how

can u post code

Jump in the discussion.

No email address required.

Posting code on a mobile is painful, but here's the process:

>Generate coordinate tuple list for the polygon's sides

>Make shapely polygon object from list

>For each xy on the grid make a shapely Point object

>Call polygon.contains(point) to figure out if it's inside. Count positives for the area in pixels

Of course that's retarded and won't work for Part 2, so just use the proper theorum of polygon area + half polygon perimeter +1 to convert geometry based area to touched pixels

Jump in the discussion.

No email address required.

>shoutout to whoever mentioned point in polygon a couple days ago

:marseywav#e2:

Jump in the discussion.

No email address required.

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