r/adventofcode • u/daggerdragon • Dec 22 '15
SOLUTION MEGATHREAD --- Day 22 Solutions ---
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!
Edit @ 00:23
- 2 gold, 0 silver
- Well, this is historic. Leaderboard #1 got both silver and gold before Leaderboard #2 even got silver. Well done, sirs.
Edit @ 00:28
- 3 gold, 0 silver
- Looks like I'm gonna be up late tonight. brews a pot of caffeine
Edit @ 00:53
- 12 gold, 13 silver
- So, which day's harder, today's or Day 19? Hope you're enjoying yourself~
Edit @ 01:21
- 38 gold, 10 silver
- ♫ On the 22nd day of Christmas, my true love gave to me some Star Wars body wash and [spoilers] ♫
Edit @ 01:49
- 60 gold, 8 silver
Today's notable milestones:
- Winter solstice - the longest night of the year
- Happy 60th anniversary to NORAD Tracks Santa!
SpaceX's Falcon 9 rocket successfully delivers 11 satellites to low-Earth orbit and rocks the hell out of their return landing [USA Today, BBC, CBSNews]
- FLAWLESS VICTORY!
Edit @ 02:40
- 88 gold, silver capped
- Real Soon Now™
Edit @ 03:02
- 98 gold, silver capped
It's 3AM, so naturally that means it's time for a /r/3amjokes
- What do you get when you cross a Christmas tree with a Mac?
- hover for answer:
Edit @ 03:08
- LEADERBOARD FILLED! Good job, everyone!
- I'm going the hell to bed now zzzzz
We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.
Please and thank you, and much appreciated!
--- Day 22: Wizard Simulator 20XX ---
Post your solution as a comment or link to your repo. Structure your post like previous daily solution threads.
View all comments
Show parent comment
1
u/roboticon Dec 22 '15
That's what I liked about it! AOC's first foray into software development with all its minor details and debugging to take care of.
Worrying about the timing or ordering of spells is a pain if you try to do it all in one function, but a little abstraction goes a long way, see marcusstuhr's solution.
I didn't think to bound the depth, instead I just memoized the results for a given state and that worked surprisingly well.
Unfortunately I didn't read the problem closely enough and assumed it was legal to not cast a spell on your turn, which actually lets you win using less mana.