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 (4931B)


      1--- Day 10: The Stars Align ---
      2
      3It's no use; your navigation system simply isn't capable of providing walking directions in the
      4arctic circle, and certainly not in 1018.
      5
      6The Elves suggest an alternative. In times like these, North Pole rescue operations will arrange
      7points of light in the sky to guide missing Elves back to base. Unfortunately, the message is easy
      8to miss: the points move slowly enough that it takes hours to align them, but have so much momentum
      9that they only stay aligned for a second. If you blink at the wrong time, it might be hours before
     10another message appears.
     11
     12You can see these points of light floating in the distance, and record their position in the sky and
     13their velocity, the relative change in position per second (your puzzle input). The coordinates are
     14all given from your perspective; given enough time, those positions and velocities will move the
     15points into a cohesive message!
     16
     17Rather than wait, you decide to fast-forward the process and calculate what the points will
     18eventually spell.
     19
     20For example, suppose you note the following points:
     21
     22position=< 9,  1> velocity=< 0,  2>
     23position=< 7,  0> velocity=<-1,  0>
     24position=< 3, -2> velocity=<-1,  1>
     25position=< 6, 10> velocity=<-2, -1>
     26position=< 2, -4> velocity=< 2,  2>
     27position=<-6, 10> velocity=< 2, -2>
     28position=< 1,  8> velocity=< 1, -1>
     29position=< 1,  7> velocity=< 1,  0>
     30position=<-3, 11> velocity=< 1, -2>
     31position=< 7,  6> velocity=<-1, -1>
     32position=<-2,  3> velocity=< 1,  0>
     33position=<-4,  3> velocity=< 2,  0>
     34position=<10, -3> velocity=<-1,  1>
     35position=< 5, 11> velocity=< 1, -2>
     36position=< 4,  7> velocity=< 0, -1>
     37position=< 8, -2> velocity=< 0,  1>
     38position=<15,  0> velocity=<-2,  0>
     39position=< 1,  6> velocity=< 1,  0>
     40position=< 8,  9> velocity=< 0, -1>
     41position=< 3,  3> velocity=<-1,  1>
     42position=< 0,  5> velocity=< 0, -1>
     43position=<-2,  2> velocity=< 2,  0>
     44position=< 5, -2> velocity=< 1,  2>
     45position=< 1,  4> velocity=< 2,  1>
     46position=<-2,  7> velocity=< 2, -2>
     47position=< 3,  6> velocity=<-1, -1>
     48position=< 5,  0> velocity=< 1,  0>
     49position=<-6,  0> velocity=< 2,  0>
     50position=< 5,  9> velocity=< 1, -2>
     51position=<14,  7> velocity=<-2,  0>
     52position=<-3,  6> velocity=< 2, -1>
     53
     54Each line represents one point. Positions are given as <X, Y> pairs: X represents how far left
     55(negative) or right (positive) the point appears, while Y represents how far up (negative) or down
     56(positive) the point appears.
     57
     58At 0 seconds, each point has the position given. Each second, each point's velocity is added to its
     59position. So, a point with velocity <1, -2> is moving to the right, but is moving upward twice as
     60quickly. If this point's initial position were <3, 9>, after 3 seconds, its position would become
     61<6, 3>.
     62
     63Over time, the points listed above would move like this:
     64
     65Initially:
     66........#.............
     67................#.....
     68.........#.#..#.......
     69......................
     70#..........#.#.......#
     71...............#......
     72....#.................
     73..#.#....#............
     74.......#..............
     75......#...............
     76...#...#.#...#........
     77....#..#..#.........#.
     78.......#..............
     79...........#..#.......
     80#...........#.........
     81...#.......#..........
     82
     83After 1 second:
     84......................
     85......................
     86..........#....#......
     87........#.....#.......
     88..#.........#......#..
     89......................
     90......#...............
     91....##.........#......
     92......#.#.............
     93.....##.##..#.........
     94........#.#...........
     95........#...#.....#...
     96..#...........#.......
     97....#.....#.#.........
     98......................
     99......................
    100
    101After 2 seconds:
    102......................
    103......................
    104......................
    105..............#.......
    106....#..#...####..#....
    107......................
    108........#....#........
    109......#.#.............
    110.......#...#..........
    111.......#..#..#.#......
    112....#....#.#..........
    113.....#...#...##.#.....
    114........#.............
    115......................
    116......................
    117......................
    118
    119After 3 seconds:
    120......................
    121......................
    122......................
    123......................
    124......#...#..###......
    125......#...#...#.......
    126......#...#...#.......
    127......#####...#.......
    128......#...#...#.......
    129......#...#...#.......
    130......#...#...#.......
    131......#...#..###......
    132......................
    133......................
    134......................
    135......................
    136
    137After 4 seconds:
    138......................
    139......................
    140......................
    141............#.........
    142........##...#.#......
    143......#.....#..#......
    144.....#..##.##.#.......
    145.......##.#....#......
    146...........#....#.....
    147..............#.......
    148....#......#...#......
    149.....#.....##.........
    150...............#......
    151...............#......
    152......................
    153......................
    154
    155After 3 seconds, the message appeared briefly: HI. Of course, your message will be much longer and
    156will take many more seconds to appear.
    157
    158What message will eventually appear in the sky?
    159
    160