r/adventofcode • • Dec 23 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 23 Solutions -🎄-

--- Day 23: Experimental Emergency Teleportation ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 23

Transcript:

It's dangerous to go alone! Take this: ___


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked at 01:40:41!

22 Upvotes

205 comments sorted by

View all comments

Show parent comment

4

u/jwise00 Dec 23 '18 edited Dec 23 '18

41/34. I did it approx. this way, too, except my command of Python is not good enough to do that at what I considered to be comp speed, and I didn't know Z3 either. So I modified my existing Lua to generate some Z3lisp.

It is very rare that the leaderboard moves slow enough that I get to learn an entirely new technology that I've only heard of the concepts of before, but never used, and still solve in 34!

I had a prolog of z3lisp:

https://github.com/jwise/aoc/blob/master/2018/23.z3header

Some Lua that generated some more z3lisp:

https://github.com/jwise/aoc/blob/master/2018/23.lua

And an epilog that actually sets up and does the computation:

https://github.com/jwise/aoc/blob/master/2018/23.z3footer

To see what it looks like all put together, the sample looks like this:

http://nyus.joshuawise.com/23.z3small

As sully noted, it seems to work fine (and take 20 seconds less to execute) if you comment out the (minimize (dist 0 0 0 x y z)).

What a fun problem! I figured initially that z3 was possible because I saw someone tag it in 13 minutes, shitposted on IRC that probably /u/mserrano was doing it in z3, and then /u/msully4321 beat him to the punch... We were kind of curious after we had solved it whether anyone solved it the 'legit' way, and I was sort of surprised to see that most people did.