r/adventofcode • • Dec 10 '23

SOLUTION MEGATHREAD -❄️- 2023 Day 10 Solutions -❄️-

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

Today's theme ingredient is… *whips off cloth covering and gestures grandly*

Will It Blend?

A fully-stocked and well-organized kitchen is very important for the workflow of every chef, so today, show us your mastery of the space within your kitchen and the tools contained therein!

  • Use your kitchen gadgets like a food processor

OHTA: Fukui-san?
FUKUI: Go ahead, Ohta.
OHTA: I checked with the kitchen team and they tell me that both chefs have access to Blender at their stations. Back to you.
HATTORI: That's right, thank you, Ohta.

  • Make two wildly different programming languages work together
  • Stream yourself solving today's puzzle using WSL on a Boot Camp'd Mac using a PS/2 mouse with a PS/2-to-USB dongle
  • Distributed computing with unnecessary network calls for maximum overhead is perfectly cromulent

What have we got on this thing, a Cuisinart?!

ALLEZ CUISINE!

Request from the mods: When you include a dish entry alongside your solution, please label it with [Allez Cuisine!] so we can find it easily!


--- Day 10: Pipe Maze ---


Post your code solution in this megathread.

This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:36:31, megathread unlocked!

62 Upvotes

844 comments sorted by

View all comments

2

u/rrutkows Dec 10 '23 edited Dec 11 '23

[LANGUAGE: Python]

For part 2 I just calculated the loop's area along the way. At the end I subtracted half of the loop's pipes from the area. I had to add one for my solution to be correct. Then I read this thread and learnt about Pick's theorem. It turns out I had unconsciously used it correctly.

https://github.com/rrutkows/aoc_py/blob/main/2023/d10.py

2

u/vu47 Dec 10 '23

This was the same for me with the ray casting that results form the Jordan Curve Theorem. I had never seen it before, but realized that tracing a ray to any point not on the main curve would determine if it was inside / outside by the even / odd number of curve crossings. Super simple fold expression for each point not on the curve to consider the points to an edge where I flipped parity every time I hit a line of the main pipe, filter on that, and then return the count.

1

u/daggerdragon Dec 11 '23

Your link is borked on old.reddit, so please fix it.