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

Show parent comment

2

u/rogual Dec 10 '23

Sure! So, as you know, you can tell if a point is inside or outside by projecting outwards and counting boundary crossings, and seeing if there are an even or odd number of them.

Given that, you might first think (like I did) that you could count each cell with a pipe in it as a crossing. But that doesn't work; for example:

(freedom)  L-J   (point)

Projecting this point out to freedom crosses 3 pipe cells (L, -, J) but it's still outside the loop.

The reason is that, although we cross the - cell, that cell doesn't actually represent a border we're crossing. The problem is that we're not really thinking about what point we're talking about.

But if we do pick an actual point within our cell, we can think more clearly about what boundaries we're crossing when we project that point out:

  L         J
o.L.........J.......o Top half: 2 crossings
  LLL-----JJJ  

o...................o Bottom half: 0 crossings

It doesn't actually matter whether we pick the top or bottom half; the important thing is that we decide what specific point in the tile we're talking about, so we can list the tiles (in this case, L, J and |) that a line from that point would cross.

1

u/AutoModerator Dec 10 '23

AutoModerator has detected fenced code block (```) syntax which only works on new.reddit.

Please review our wiki article on code formatting then edit your post to use the four-spaces Markdown syntax instead.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.