description.txt 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --- Day 18: RAM Run ---
  2. You and The Historians look a lot more pixelated than you remember. You're inside a computer at the North Pole!
  3. Just as you're about to check out your surroundings, a program runs up to you. "This region of memory isn't safe! The User misunderstood what a pushdown automaton is and their algorithm is pushing whole bytes down on top of us! Run!"
  4. The algorithm is fast - it's going to cause a byte to fall into your memory space once every nanosecond! Fortunately, you're faster, and by quickly scanning the algorithm, you create a list of which bytes will fall (your puzzle input) in the order they'll land in your memory space.
  5. Your memory space is a two-dimensional grid with coordinates that range from 0 to 70 both horizontally and vertically. However, for the sake of example, suppose you're on a smaller grid with coordinates that range from 0 to 6 and the following list of incoming byte positions:
  6. 5,4
  7. 4,2
  8. 4,5
  9. 3,0
  10. 2,1
  11. 6,3
  12. 2,4
  13. 1,5
  14. 0,6
  15. 3,3
  16. 2,6
  17. 5,1
  18. 1,2
  19. 5,5
  20. 2,5
  21. 6,5
  22. 1,4
  23. 0,4
  24. 6,4
  25. 1,1
  26. 6,1
  27. 1,0
  28. 0,5
  29. 1,6
  30. 2,0
  31. Each byte position is given as an X,Y coordinate, where X is the distance from the left edge of your memory space and Y is the distance from the top edge of your memory space.
  32. You and The Historians are currently in the top left corner of the memory space (at 0,0) and need to reach the exit in the bottom right corner (at 70,70 in your memory space, but at 6,6 in this example). You'll need to simulate the falling bytes to plan out where it will be safe to run; for now, simulate just the first few bytes falling into your memory space.
  33. As bytes fall into your memory space, they make that coordinate corrupted. Corrupted memory coordinates cannot be entered by you or The Historians, so you'll need to plan your route carefully. You also cannot leave the boundaries of the memory space; your only hope is to reach the exit.
  34. In the above example, if you were to draw the memory space after the first 12 bytes have fallen (using . for safe and # for corrupted), it would look like this:
  35. ...#...
  36. ..#..#.
  37. ....#..
  38. ...#..#
  39. ..#..#.
  40. .#..#..
  41. #.#....
  42. You can take steps up, down, left, or right. After just 12 bytes have corrupted locations in your memory space, the shortest path from the top left corner to the exit would take 22 steps. Here (marked with O) is one such path:
  43. OO.#OOO
  44. .O#OO#O
  45. .OOO#OO
  46. ...#OO#
  47. ..#OO#.
  48. .#.O#..
  49. #.#OOOO
  50. Simulate the first kilobyte (1024 bytes) falling onto your memory space. Afterward, what is the minimum number of steps needed to reach the exit?
  51. Your puzzle answer was 356.
  52. --- Part Two ---
  53. The Historians aren't as used to moving around in this pixelated universe as you are. You're afraid they're not going to be fast enough to make it to the exit before the path is completely blocked.
  54. To determine how fast everyone needs to go, you need to determine the first byte that will cut off the path to the exit.
  55. In the above example, after the byte at 1,1 falls, there is still a path to the exit:
  56. O..#OOO
  57. O##OO#O
  58. O#OO#OO
  59. OOO#OO#
  60. ###OO##
  61. .##O###
  62. #.#OOOO
  63. However, after adding the very next byte (at 6,1), there is no longer a path to the exit:
  64. ...#...
  65. .##..##
  66. .#..#..
  67. ...#..#
  68. ###..##
  69. .##.###
  70. #.#....
  71. So, in this example, the coordinates of the first byte that prevents the exit from being reachable are 6,1.
  72. Simulate more of the bytes that are about to corrupt your memory space. What are the coordinates of the first byte that will prevent the exit from being reachable from your starting position? (Provide the answer as two integers separated by a comma with no other characters.)
  73. Your puzzle answer was 22,33.
  74. Both parts of this puzzle are complete! They provide two gold stars: **