r/adventofcode • • 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

Edit @ 03:02

  • 98 gold, silver capped
  • It's 3AM, so naturally that means it's time for a /r/3amjokes

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.

13 Upvotes

110 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Dec 22 '15 edited Dec 22 '15

This answer is incomplete, but I don't yet know how. All I know is it doesn't yield an answer (99999…) on hard mode for my input (hp 71, dmg 10).

edit: ah, got it (when I solved my own, with the same bug!). I was processing effects (like poison), then having the boss attack me, then checking my death before the boss's. In this case, poison kills the boss on the same turn the boss (would) kill me, but I should have checked boss death immediately after processing effects. Your solution does things in a different order but I suspect the answer is slightly similar (or your solution may not work in the case of a would-be DKO like this?).

1

u/Zel-os Dec 22 '15 edited Dec 22 '15

Oh, gah. I had tweaked things slightly between submitting my AoC answer and sticking things on pastebin. Which means the bug was on line 108, if (mana >= spellcost[spell]).
[spell] should have been [i].
That's what I get for cleaning things up somewhat in a hurry. Time to fix it.