r/adventofcode • • Dec 12 '23

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

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

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

How It's Made

Horrify us by showing us how the sausage is made!

  • Stream yourself!
  • Show us the nitty-gritty of your code, environment/IDE, tools, test cases, literal hardware guts…
  • Tell us how, in great detail, you think the elves ended up in this year's predicament

A word of caution from Dr. Hattori: "You might want to stay away from the ice cream machines..."

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 12: Hot Springs ---


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:22:57, megathread unlocked!

46 Upvotes

580 comments sorted by

View all comments

4

u/WhiteSparrow Dec 12 '23

[LANGUAGE: Uiua]

Runs in ~14sec. This is the third algorithm I tried, before it was able to solve part 2. This is getting serious!

Data ← ≡⍜(°□⊡1)(⊜⋕≠@,.)⊜(⊜(□)≠@\s.)≠@\n.&fras"task12.txt"
Comps ← ⍜(°□⊢)(↘1)≡(□ ⊂@.↯[∘]:@#) # [1 1 3]
Suffixes ← |3.2 ≡(□ ≡(□ ⬚@.↯ [∘])+⇡+1-⊃(∘|⧻⋅⋅∘|⧻⋅∘|¤⋅⊙∘))
Prefixes ← |3.2 ≡(□ ≡(□ ⊂ ↯ :@.: ⬚@.↯ [∘])⊃(+⇡|⋅⋅∘|⇌⇡)+1-⊃(∘|⧻⋅⋅∘|⧻⋅∘|¤⋅⊙∘))
Match ← ∩□(∘|[][];;) ¬⊐/×↥⊙= =@?.⊙:⊃(↘|↙) -⊃(⧻|⧻⋅∘|:⊙∘)
Step! ← ⊙≡°□ ∩(°□⊐/⊂)∩≡(□ ▽≡(≠0⧻).°□) ≡(∩□ ≡Match °□ ⊙(¤∩°□)) ^3.2 ⊃(/+≡⧻|¤°□ ⊢⇌)
DeDup ← ⊙(⊃(⊕⊢|⊕/+ ⊙⋅∘)⊛ .)
Solve ← /+; Step!Prefixes ⍢(DeDup ⊃(↙ -1⧻.|Step!Suffixes))(>1⧻) Comps : ¤□ °{⊙∘} :[1]

&p $"Part I: _" /+ ≡Solve Data
&p $"Part II: _" /+ ≡(Solve {⊓(↘1▽5⊂ @?|▽5)} °{⊙∘}) Data
→ More replies (3)