Day NaN : Elvish Calendrics

Dec 26th, 2016
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Day NaN : Elvish Calendrics
  2. ===========================
  4. Back at the North Pole, the Elves are preparing a countdown to the New Year. Elf countdowns are a little unusual, because a unique sequence is used each year. Generating the sequence requires use of a prototype computer, suspiciously similar to those you have recently encountered.
  6. You notice the program contains a new instruction -- dnc -- and as you can't remember what that does, you decide to ignore it for now. Just skip over it if you encounter it during execution.
  8. The countdown sequence is generated by initialising register 'a' with the year that's ending (eg, 2016), and running the program (with other registers initialised to zero). The countdown sequence appears as outputs.
  10. Last year (2015) you distinctly remember there were 63 numbers in the countdown sequence.
  12. Your puzzle input program:
  14. Part 1:
  15. =======
  16. For this year (2016), how many numbers appear in the countdown sequence?
  19. Part 2:
  20. =======
  21. And then it comes flooding back to you -- there is an Elvish dance which accompanies each year's countdown, and that's what the dnc instruction is for!
  23. 'dnc x' reads the value contained in register x, and reduces this value modulo 7 to produce a dance step. Register x is unchanged during this process.
  25. Elf dancing is interesting in that it takes place on a hex grid, rather than a rectangular grid. You start on a hex cell, facing an adjacent cell, and each dance step is to an adjacent cell (unless otherwise stated). The dance moves are as follows:
  27. (Modulo 7)
  28. 0 : step forwards, without turning.
  29. 1 : step backwards, without turning.
  30. 2 : step to the tile 120 degrees to your left (back left), without turning.
  31. 3 : step to the tile 120 degrees to your right (back right), without turning.
  32. 4 : turn 60 degrees left, then step forward.
  33. 5 : turn 60 degrees right, then step forward.
  34. 6 : turn 180 degrees, without stepping.
  36. Loop Years are those years where the dance ends in the same grid location as it starts (the facing direction doesn't have to match). These are very special years for Elves. It has been a few hundred years since the last loop year, 1489 in fact. When will the next loop year occur?
  41. .
RAW Paste Data