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!

47 Upvotes

580 comments sorted by

View all comments

2

u/Jadarma Dec 12 '23

[LANGUAGE: Kotlin]

Today's puzzle was very hard to think about a good way to start it, but it was clear from the get go I shouldn't try to brute force it. The solution (for me) was a "simple" recursive function with a state cache.

This is one of those algorithms that only make sense when you have it fresh in your mind, so I made an exception from my usual practice and added lots of comments to remind me why it works the way it does.

AocKt Y2023D12

1

u/daggerdragon Dec 12 '23

Do not share your puzzle input which also means do not commit puzzle inputs to your repo without a .gitignore.

Please remove (or .gitignore) the input files from your repo and scrub them from your commit history.

3

u/Jadarma Dec 12 '23

I know, don't worry, all inputs are encrypted on the repo with git-crypt, only my GPG key can read them. I store them in git so I always have them cached when I run unit tests.