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


      1--- Day 11: Chronal Charge ---
      2
      3You watch the Elves and their sleigh fade into the distance as they head toward the North Pole.
      4
      5Actually, you're the one fading. The falling sensation returns.
      6
      7The low fuel warning light is illuminated on your wrist-mounted device. Tapping it once causes it to
      8project a hologram of the situation: a 300x300 grid of fuel cells and their current power levels,
      9some negative. You're not sure what negative power means in the context of time travel, but it can't
     10be good.
     11
     12Each fuel cell has a coordinate ranging from 1 to 300 in both the X (horizontal) and Y (vertical)
     13direction.  In X,Y notation, the top-left cell is 1,1, and the top-right cell is 300,1.
     14
     15The interface lets you select any 3x3 square of fuel cells. To increase your chances of getting to
     16your destination, you decide to choose the 3x3 square with the largest total power.
     17
     18The power level in a given fuel cell can be found through the following process:
     19
     20
     21 - Find the fuel cell's rack ID, which is its X coordinate plus 10.
     22
     23 - Begin with a power level of the rack ID times the Y coordinate.
     24
     25 - Increase the power level by the value of the grid serial number (your puzzle input).
     26
     27 - Set the power level to itself multiplied by the rack ID.
     28
     29 - Keep only the hundreds digit of the power level (so 12345 becomes 3; numbers with no hundreds
     30digit become 0).
     31
     32 - Subtract 5 from the power level.
     33
     34
     35For example, to find the power level of the fuel cell at 3,5 in a grid with serial number 8:
     36
     37
     38 - The rack ID is 3 + 10 = 13.
     39
     40 - The power level starts at 13 * 5 = 65.
     41
     42 - Adding the serial number produces 65 + 8 = 73.
     43
     44 - Multiplying by the rack ID produces 73 * 13 = 949.
     45
     46 - The hundreds digit of 949 is 9.
     47
     48 - Subtracting 5 produces 9 - 5 = 4.
     49
     50
     51So, the power level of this fuel cell is 4.
     52
     53Here are some more example power levels:
     54
     55
     56 - Fuel cell at  122,79, grid serial number 57: power level -5.
     57
     58 - Fuel cell at 217,196, grid serial number 39: power level  0.
     59
     60 - Fuel cell at 101,153, grid serial number 71: power level  4.
     61
     62
     63Your goal is to find the 3x3 square which has the largest total power. The square must be entirely
     64within the 300x300 grid. Identify this square using the X,Y coordinate of its top-left fuel
     65cell. For example:
     66
     67For grid serial number 18, the largest total 3x3 square has a top-left corner of 33,45 (with a total
     68power of 29); these fuel cells appear in the middle of this 5x5 region:
     69
     70-2  -4   4   4   4
     71-4   4   4   4  -5
     72 4   3   3   4  -4
     73 1   1   2   4  -3
     74-1   0   2  -5  -2
     75
     76For grid serial number 42, the largest 3x3 square's top-left is 21,61 (with a total power of 30);
     77they are in the middle of this region:
     78
     79-3   4   2   2   2
     80-4   4   3   3   4
     81-5   3   3   4  -4
     82 4   3   3   4  -3
     83 3   3   3  -5  -1
     84
     85What is the X,Y coordinate of the top-left fuel cell of the 3x3 square with the largest total
     86power?
     87
     88