aoc-2018-python

Advent of Code 2018 Solutions in Python
git clone https://git.sinitax.com/sinitax/aoc-2018-python
Log | Files | Refs | README | sfeed.txt

part1 (2852B)


      1--- Day 7: The Sum of Its Parts ---
      2
      3You find yourself standing on a snow-covered coastline; apparently, you landed a little off course. 
      4The region is too hilly to see the North Pole from here, but you do spot some Elves that seem to be
      5trying to unpack something that washed ashore. It's quite cold out, so you decide to risk creating a
      6paradox by asking them for directions.
      7
      8"Oh, are you the search party?" Somehow, you can understand whatever Elves from the year 1018 speak;
      9you assume it's Ancient Nordic Elvish. Could the device on your wrist also be a translator? "Those
     10clothes don't look very warm; take this." They hand you a heavy coat.
     11
     12"We do need to find our way back to the North Pole, but we have higher priorities at the moment. You
     13see, believe it or not, this box contains something that will solve all of Santa's transportation
     14problems - at least, that's what it looks like from the pictures in the instructions."  It doesn't
     15seem like they can read whatever language it's in, but you can: "Sleigh kit. Some assembly
     16required."
     17
     18"'Sleigh'? What a wonderful name! You must help us assemble this 'sleigh' at once!" They start
     19excitedly pulling more parts out of the box.
     20
     21The instructions specify a series of steps and requirements about which steps must be finished
     22before others can begin (your puzzle input). Each step is designated by a single letter. For
     23example, suppose you have the following instructions:
     24
     25Step C must be finished before step A can begin.
     26Step C must be finished before step F can begin.
     27Step A must be finished before step B can begin.
     28Step A must be finished before step D can begin.
     29Step B must be finished before step E can begin.
     30Step D must be finished before step E can begin.
     31Step F must be finished before step E can begin.
     32
     33Visually, these requirements look like this:
     34
     35  -->A--->B--
     36 /    \      \
     37C      -->D----->E
     38 \           /
     39  ---->F-----
     40
     41Your first goal is to determine the order in which the steps should be completed. If more than one
     42step is ready, choose the step which is first alphabetically. In this example, the steps would be
     43completed as follows:
     44
     45
     46 - Only C is available, and so it is done first.
     47
     48 - Next, both A and F are available. A is first alphabetically, so it is done next.
     49
     50 - Then, even though F was available earlier, steps B and D are now also available, and
     51B is the first alphabetically of the three.
     52
     53 - After that, only D and F are available. E is not available because only some of its prerequisites
     54are complete. Therefore, D is completed next.
     55
     56 - F is the only choice, so it is done next.
     57
     58 - Finally, E is completed.
     59
     60
     61So, in this example, the correct order is CABDFE.
     62
     63In what order should the steps in your instructions be completed?
     64
     65