Advertisement
tech_hutch

Untitled

Dec 9th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. --- Day 7: The Sum of Its Parts ---
  2.  
  3. You find yourself standing on a snow-covered coastline; apparently, you landed a little off course. The region is too hilly to see the North Pole from here, but you do spot some Elves that seem to be trying to unpack something that washed ashore. It's quite cold out, so you decide to risk creating a paradox by asking them for directions.
  4.  
  5. "Oh, are you the search party?" Somehow, you can understand whatever Elves from the year 1018 speak; you assume it's Ancient Nordic Elvish. Could the device on your wrist also be a translator? "Those clothes don't look very warm; take this." They hand you a heavy coat.
  6.  
  7. "We do need to find our way back to the North Pole, but we have higher priorities at the moment. You see, believe it or not, this box contains something that will solve all of Santa's transportation problems - at least, that's what it looks like from the pictures in the instructions." It doesn't seem like they can read whatever language it's in, but you can: "Sleigh kit. Some assembly required."
  8.  
  9. "'Sleigh'? What a wonderful name! You must help us assemble this 'sleigh' at once!" They start excitedly pulling more parts out of the box.
  10.  
  11. The instructions specify a series of steps and requirements about which steps must be finished before others can begin (your puzzle input). Each step is designated by a single letter. For example, suppose you have the following instructions:
  12.  
  13. Step C must be finished before step A can begin.
  14. Step C must be finished before step F can begin.
  15. Step A must be finished before step B can begin.
  16. Step A must be finished before step D can begin.
  17. Step B must be finished before step E can begin.
  18. Step D must be finished before step E can begin.
  19. Step F must be finished before step E can begin.
  20.  
  21. Visually, these requirements look like this:
  22.  
  23.  
  24. -->A--->B--
  25. / \ \
  26. C -->D----->E
  27. \ /
  28. ---->F-----
  29.  
  30. Your first goal is to determine the order in which the steps should be completed. If more than one step is ready, choose the step which is first alphabetically. In this example, the steps would be completed as follows:
  31.  
  32. Only C is available, and so it is done first.
  33. Next, both A and F are available. A is first alphabetically, so it is done next.
  34. Then, even though F was available earlier, steps B and D are now also available, and B is the first alphabetically of the three.
  35. After that, only D and F are available. E is not available because only some of its prerequisites are complete. Therefore, D is completed next.
  36. F is the only choice, so it is done next.
  37. Finally, E is completed.
  38.  
  39. So, in this example, the correct order is CABDFE.
  40.  
  41. In what order should the steps in your instructions be completed?
  42.  
  43. Your puzzle answer was ABLCFNSXZPRHVEGUYKDIMQTWJO.
  44.  
  45. The first half of this puzzle is complete! It provides one gold star: *
  46.  
  47.  
  48. --- Part Two ---
  49.  
  50. As you're about to begin construction, four of the Elves offer to help. "The sun will set soon; it'll go faster if we work together." Now, you need to account for multiple people working on steps simultaneously. If multiple steps are available, workers should still begin them in alphabetical order.
  51.  
  52. Each step takes 60 seconds plus an amount corresponding to its letter: A=1, B=2, C=3, and so on. So, step A takes 60+1=61 seconds, while step Z takes 60+26=86 seconds. No time is required between steps.
  53.  
  54. To simplify things for the example, however, suppose you only have help from one Elf (a total of two workers) and that each step takes 60 fewer seconds (so that step A takes 1 second and step Z takes 26 seconds). Then, using the same instructions as above, this is how each second would be spent:
  55.  
  56. Second Worker 1 Worker 2 Done
  57. 0 C .
  58. 1 C .
  59. 2 C .
  60. 3 A F C
  61. 4 B F CA
  62. 5 B F CA
  63. 6 D F CAB
  64. 7 D F CAB
  65. 8 D F CAB
  66. 9 D . CABF
  67. 10 E . CABFD
  68. 11 E . CABFD
  69. 12 E . CABFD
  70. 13 E . CABFD
  71. 14 E . CABFD
  72. 15 . . CABFDE
  73.  
  74. Each row represents one second of time. The Second column identifies how many seconds have passed as of the beginning of that second. Each worker column shows the step that worker is currently doing (or . if they are idle). The Done column shows completed steps.
  75.  
  76. Note that the order of the steps has changed; this is because steps now take time to finish and multiple workers can begin multiple steps simultaneously.
  77.  
  78. In this example, it would take 15 seconds for two workers to complete these steps.
  79.  
  80. With 5 workers and the 60+ second step durations described above, how long will it take to complete all of the steps?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement