day11: Day 11: Chronal Charge

Description Usage Arguments Details Value Examples

Description

Chronal Charge

Usage

1
2
3
4
5
6
7
pool_power_cells(mat, pool_span, fun = sum)

compute_cell_power_level(x, y, serial_number)

create_power_cell_matrix(span, serial_number)

search_power_cell_pools(mat, to_search = NULL)

Arguments

x

some data

Details

Part One

You watch the Elves and their sleigh fade into the distance as they head toward the North Pole.

Actually, you're the one fading. The [falling sensation]title="wheeeeeeeeeeeeeeeeee" returns.

The low fuel warning light is illuminated on your wrist-mounted device. Tapping it once causes it to project a hologram of the situation: a 300x300 grid of fuel cells and their current power levels, some negative. You're not sure what negative power means in the context of time travel, but it can't be good.

Each fuel cell has a coordinate ranging from 1 to 300 in both the X (horizontal) and Y (vertical) direction. In X,Y notation, the top-left cell is 1,1, and the top-right cell is 300,1.

The interface lets you select any 3x3 square of fuel cells. To increase your chances of getting to your destination, you decide to choose the 3x3 square with the largest total power.

The power level in a given fuel cell can be found through the following process:

For example, to find the power level of the fuel cell at 3,5 in a grid with serial number 8:

So, the power level of this fuel cell is 4.

Here are some more example power levels:

Your goal is to find the 3x3 square which has the largest total power. The square must be entirely within the 300x300 grid. Identify this square using the X,Y coordinate of its top-left fuel cell. For example:

For grid serial number 18, the largest total 3x3 square has a top-left corner of 33,45 (with a total power of 29); these fuel cells appear in the middle of this 5x5 region:

1
2
3
4
5
-2  -4   4   4   4
-4   4   4   4  -5
 4   3   3   4  -4
 1   1   2   4  -3
-1   0   2  -5  -2

For grid serial number 42, the largest 3x3 square's top-left is 21,61 (with a total power of 30); they are in the middle of this region:

1
2
3
4
5
-3   4   2   2   2
-4   4   3   3   4
-5   3   3   4  -4
 4   3   3   4  -3
 3   3   3  -5  -1

What is the X,Y coordinate of the top-left fuel cell of the 3x3 square with the largest total power?

Part Two

(Use have to manually add this yourself.)

(Try using convert_clipboard_html_to_roxygen_md())

Value

For Part One, f11a(x) returns .... For Part Two, f11b(x) returns ....

Examples

1
2
f11a()
f11b()

tjmahr/adventofcode18 documentation built on May 24, 2019, 4:10 p.m.