DEV Community

Cover image for Advent of Code 2019 Solution Megathread - Day 25: Cryostasis
Jon Bristow
Jon Bristow

Posted on

Advent of Code 2019 Solution Megathread - Day 25: Cryostasis

Merry Christmas!

Day 25 - The Problem

We made it to Santa's location! Woo!

Hmm, maybe my celebratory dance was a little premature. Everything is too quiet.

Also really cold.

Since it's too dangerous, let's boot up our IntCode computer one last time as a live droid control interface and inspect the conditions of Santa's ship.

That's right, Part 1 (if you're not cheating, which is its own reward) is using our IntCode computers to play a Zork clone to navigate the ship, collect items, and bypass the weight checking security checkpoint.

Once we get the password to get on board, Santa greets us and requests 49 stars to re-calibrate the ship. Part 2 only requires that you complete all the other days with 2 stars.

Ongoing Meta

Dev.to List of Leaderboards

If you were part of Ryan Palo's leaderboard last year, you're still a member of that!

If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "Private Leaderboard" page.)

I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.

There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" and a language specific one if you want.

Top comments (2)

Collapse
 
jbristow profile image
Jon Bristow • Edited

I didn't actually write more than a handful of lines of new code!

Mostly, I just reused the breakout clone (ascii output to screen) and added a blocking stdin read in the "input" section.

private fun Cryostasis.sendInput(): Cryostasis {
    return state.fold(
        ifLeft = { this },
        ifRight = {
            when {
                it.waitingForInput -> {
                    if (initalCommands.isNotEmpty()) {
                        it.inputs.addAll(initalCommands.pop().map(Char::toLong))
                    } else {
                        val enteredString = readLine()
                        it.inputs.addAll(enteredString!!.map(Char::toLong))
                        it.inputs.add(10L)
                    }
                    this.copy(saveState = code.toMap())
                }
                else -> {
                    this
                }
            }
        }
    )
}

As you can see, after game-overing myself a few times (Eaten by a grue! You'd think I'd learn after all these years!) I found it necessary to pipe in a pre-formatted set of inputs to bootstrap me back to the state I was in before.

I played around trying to see if there was an obvious way to cheat, but in the end I just wandered around and then did a manual DFS of the items to get my way through the security checkpoint.

Merry Christmas everyone! Thanks for sharing your work with me! I hope you had fun!

Collapse
 
jbristow profile image
Jon Bristow

Here's a rudimentary map I made in excel: i.imgur.com/hW2bFJw.png