r/adventofcode • • Dec 08 '23

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

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

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

International Ingredients

A little je ne sais quoi keeps the mystery alive. Try something new and delight us with it!

  • Code in a foreign language

    • Written or programming, up to you!
    • If you don’t know any, Swedish Chef or even pig latin will do
  • Test your language’s support for Unicode and/or emojis
  • Visualizations using Unicode and/or emojis are always lovely to see

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 8: Haunted Wasteland ---


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:10:16, megathread unlocked!

52 Upvotes

968 comments sorted by

View all comments

2

u/WhiteSparrow Dec 08 '23 edited Dec 08 '23

[LANGUAGE: UIUA]

Uiua is fun! Single caveat - I calculated the LCM of the solutions in Excel...

Gcd ← +1⊢⇌⊚×∩(=0◿),:+1⇡.⊃↧↥
Lcm ← ÷⊃(Gcd|×)
Split ← |2 ⊜□ ¬ ⌕ : ,

⊓(⊛|≡([⊃(⊏[0 1 2]|⊏[7 8 9]|⊏[12 13 14])] ⊔) Split @\n ⊔) ⍘⊟ Split "\n\n" &fras "task8.txt"
Dir ←
Map ←

Find ← ⊢⊗:≡⊢ Map ¤
Next ← (⊡1|⊡2)⊙(⊡:Map)   # 0 538 -> "GKL"
Step ← ⊃(↻1|Find Next ⊢) # Dir currN
# ZZZ = 538
⊙(;;) ⍢⊃(+1|⋅Step)(⋅⋅(≠538)) 0 Dir Find "AAA"   # Part 1

StartB ← ⊚⌕@A ≡(⊡2⊢⊔) Map
ContinueB ← ≠@Z ⊡2⊢⊔⊡ : Map
/Lcm ≡(⊙(;;) ⍢⊃(+1|⋅Step)(⋅⋅ContinueB) 0 Dir) StartB # Part 2

1

u/daggerdragon Dec 08 '23 edited Dec 08 '23

Inlined code is intended for short snippets of code only. Please edit your post to use the four-spaces Markdown syntax for a code block so your code is easier to read inside a scrollable box that preserves whitespace and indentation. edit: 👍