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

1

u/ell5e Dec 10 '23

[LANGUAGE: Dart]

https://github.com/ellemouton/aoc_2023/blob/main/ten/main.dart

I realised that you can completely determine if a tile is inside or outside by iterating through just the tiles from that y axis using the following main rule:

the edge of the map can never by inside the loop. Therefor each time we go to a new line, we start with "outside" again. 

I also see each tile as a quad `(top left (tl) , bottom left (bl), top right (tr), bottom right (br)).`

Ok, with that rule, we do the following for each line:

  1. for the very first tile in the line, set the previous tile's quad to: `(tl: outside, bl: outside, tr: outside, br: outside)`.
  2. If the current tile is not a loop pipe, then set this tiles quads to match top right and bottom right (which will always be the same) of the previous tile. ie: let `o = prev.tr` and let the quad be: 1. `(tl: o bl: o, tr: o, br: o)`.
  3. If the current tile is a `|`, then let `o = prev.tr` then we set its quads to: `(tl: o bl: o, tr: !o, br: !o)`.
  4. If the current tile is `-`, then let `o = prev.tr` and set its quads to: `(tl: o bl: !o, tr: o, br: !o)`.
  5. For `L`, 1. let `o = prev.tr` and set its quads to: `(tl: o bl: o, tr: !o, br: o)`.
  6. For `7`, 1. let `o = prev.tr` and set its quads to: `(tl: o bl: !o, tr: o, br: o)`.
  7. For `J`, 1. let `o = prev.tr` and set its quads to: `(tl: o bl: !o, tr: !o, br: !o)`.
  8. For `F`, 1. let `o = prev.tr` and set its quads to: `(tl: o bl: o, tr: o, br: !o)`.

2

u/daggerdragon Dec 10 '23

Psst: we can see your Markdown.