aoc-2019-c

Advent of Code 2019 Solutions in C
git clone https://git.sinitax.com/sinitax/aoc-2019-c
Log | Files | Refs | README | sfeed.txt

part2 (2564B)


      1--- Part Two ---
      2
      3You aren't sure how large Santa's ship is. You aren't even sure if you'll need to use this thing on
      4Santa's ship, but it doesn't hurt to be prepared. You figure Santa's ship might fit in a
      5100x100 square.
      6
      7The beam gets wider as it travels away from the emitter; you'll need to be a minimum distance away
      8to fit a square of that size into the beam fully. (Don't rotate the square; it should be aligned to
      9the same axes as the drone grid.)
     10
     11For example, suppose you have the following tractor beam readings:
     12
     13#.......................................
     14.#......................................
     15..##....................................
     16...###..................................
     17....###.................................
     18.....####...............................
     19......#####.............................
     20......######............................
     21.......#######..........................
     22........########........................
     23.........#########......................
     24..........#########.....................
     25...........##########...................
     26...........############.................
     27............############................
     28.............#############..............
     29..............##############............
     30...............###############..........
     31................###############.........
     32................#################.......
     33.................########OOOOOOOOOO.....
     34..................#######OOOOOOOOOO#....
     35...................######OOOOOOOOOO###..
     36....................#####OOOOOOOOOO#####
     37.....................####OOOOOOOOOO#####
     38.....................####OOOOOOOOOO#####
     39......................###OOOOOOOOOO#####
     40.......................##OOOOOOOOOO#####
     41........................#OOOOOOOOOO#####
     42.........................OOOOOOOOOO#####
     43..........................##############
     44..........................##############
     45...........................#############
     46............................############
     47.............................###########
     48
     49In this example, the 10x10 square closest to the emitter that fits entirely within the tractor beam
     50has been marked O. Within it, the point closest to the emitter (the only highlighted O) is at X=25,
     51Y=20.
     52
     53Find the 100x100 square closest to the emitter that fits entirely within the tractor beam; within
     54that square, find the point closest to the emitter.  What value do you get if you take that point's
     55X coordinate, multiply it by 10000, then add the point's Y coordinate? (In the example above, this
     56would be 250020.)
     57
     58