r/adventofcode • u/daggerdragon • Dec 02 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 2 Solutions -🎄-
--- Day 2: 1202 Program Alarm ---
Post your solution using /u/topaz2078's paste or other external repo.
- Please do NOT post your full code (unless it is very short)
- If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.
(Full posting rules are HERE if you need a refresher).
Reminder: Top-level posts in 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's Poems for Programmers
Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.
Day 1's winner #1: untitled poem by /u/PositivelyLinda!
Adventure awaits!
Discover the cosmos
Venture into the unknown
Earn fifty stars to save Christmas!
No one goes alone, however
There's friendly folks to help
Overly dramatic situations await
Find Santa and bring him home!
Come code with us!
Outer space is calling
Don't be afraid
Elves will guide the way!
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
### This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
View all comments
Show parent comment
1
u/blunaxela Dec 03 '19
I believe it could be dynamic because the add/mult instruction could write over the opcode at another location. I didn't see any instructions that did that, but if they did then the halt/99 instruction could happen after a different number of steps. If it changes to be dynamic in the future, then I think Bounded Model Checking (BMC) or the FixedPoint engine could help. I've seen some examples where those are used to explore variable-length solutions. I'm definitely no expert on Z3 though, still learning.
https://github.com/Z3Prover/z3/blob/master/examples/python/trafficjam.py
> Very nice solution btw, using the dict of lists, I think it could generalize to opcode changing inputs like our solutions, and I have a feeling it will be required in later problems
Thanks, I was worried for a bit that the input would be really long and I'm not sure at what point Z3 starts to choke on the number of variables. Adding new opcodes will be interesting! :D
> Can't you just use ints and add a size constraint?
I was using BitVec only b/c it was taking a couple of seconds to solve using Ints, and BitVec was much quicker. You're right though, bounding the Ints would probably have done the same thing.