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


      1--- Day 6: Chronal Coordinates ---
      2
      3The device on your wrist beeps several times, and once again you feel like you're falling.
      4
      5"Situation critical," the device announces. "Destination indeterminate. Chronal interference
      6detected. Please specify new target coordinates."
      7
      8The device then produces a list of coordinates (your puzzle input). Are they places it thinks are
      9safe or dangerous? It recommends you check manual page 729. The Elves did not give you a manual.
     10
     11If they're dangerous, maybe you can minimize the danger by finding the coordinate that gives the
     12largest distance from the other points.
     13
     14Using only the Manhattan distance, determine the area around each coordinate by counting the number
     15of integer X,Y locations that are closest to that coordinate (and aren't tied in distance to any
     16other coordinate).
     17
     18Your goal is to find the size of the largest area that isn't infinite. For example, consider the
     19following list of coordinates:
     20
     211, 1
     221, 6
     238, 3
     243, 4
     255, 5
     268, 9
     27
     28If we name these coordinates A through F, we can draw them on a grid, putting 0,0 at the top left:
     29
     30..........
     31.A........
     32..........
     33........C.
     34...D......
     35.....E....
     36.B........
     37..........
     38..........
     39........F.
     40
     41This view is partial - the actual grid extends infinitely in all directions.  Using the Manhattan
     42distance, each location's closest coordinate can be determined, shown here in lowercase:
     43
     44aaaaa.cccc
     45aAaaa.cccc
     46aaaddecccc
     47aadddeccCc
     48..dDdeeccc
     49bb.deEeecc
     50bBb.eeee..
     51bbb.eeefff
     52bbb.eeffff
     53bbb.ffffFf
     54
     55Locations shown as . are equally far from two or more coordinates, and so they don't count as being
     56closest to any.
     57
     58In this example, the areas of coordinates A, B, C, and F are infinite - while not shown here, their
     59areas extend forever outside the visible grid. However, the areas of coordinates D and E are finite:
     60D is closest to 9 locations, and E is closest to 17 (both including the coordinate's location
     61itself).  Therefore, in this example, the size of the largest area is 17.
     62
     63What is the size of the largest area that isn't infinite?
     64
     65