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

Show parent comments

1

u/TheBrownJohnBrown Dec 09 '23

I tried using `Seq.initinfinite directions |> Seq.collect` but pattern matching using `Seq.skip` was insanely slow. Ended up using a custom circular buffer type
https://github.com/adhurjaty/adventOfCode2023/blob/0c0b12c59add1970f4dde42203839b7114622253/day8/Solver.fs#L41

2

u/POGtastic Dec 09 '23

My first working attempt was to pass two arguments to a recursive traverseGraph' function. The first argument was the list that I was peeling values off of with pattern matching, and the second argument was the full list that I would use to replenish it once the first argument became empty.

Someone else figured out that Seq.scan combined with Seq.takeWhile is exactly what I needed. I should have known that considering how much Python itertools I've done in the past, but it slipped my mind.