34e9731a520dab231d60237bd58bb5a6d0b54fea
—
Christopher Vittal
2 years ago
0ded1d6

Add descriptions for days 11 to 13

3 files changed,473insertions(+),0deletions(-) A descriptions/Day11.md A descriptions/Day12.md A descriptions/Day13.md

A descriptions/Day11.md => descriptions/Day11.md +105 -0

@@ 0,0 1,105 @@\-\-- Day 11: Chronal Charge \-\-- ---------------------------------- 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: - Find the fuel cell\'s *rack ID*, which is its *X coordinate plus 10*. - Begin with a power level of the *rack ID* times the *Y coordinate*. - Increase the power level by the value of the *grid serial number* (your puzzle input). - Set the power level to itself multiplied by the *rack ID*. - Keep only the *hundreds digit* of the power level (so `12345` becomes `3`; numbers with no hundreds digit become `0`). - *Subtract 5* from the power level. For example, to find the power level of the fuel cell at `3,5` in a grid with serial number `8`: - The rack ID is `3 + 10 = 13`. - The power level starts at `13 * 5 = 65`. - Adding the serial number produces `65 + 8 = 73`. - Multiplying by the rack ID produces `73 * 13 = 949`. - The hundreds digit of `949` is `9`. - Subtracting 5 produces `9 - 5 = 4`. So, the power level of this fuel cell is `4`. Here are some more example power levels: - Fuel cell at `122,79`, grid serial number `57`: power level `-5`. - Fuel cell at `217,196`, grid serial number `39`: power level `0`. - Fuel cell at `101,153`, grid serial number `71`: power level `4`. 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: -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: -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 \-\-- {#part2} -------------------- You discover a dial on the side of the device; it seems to let you select a square of *any size*, not just 3x3. Sizes from 1x1 to 300x300 are supported. Realizing this, you now must find the *square of any size with the largest total power*. Identify this square by including its size as a third parameter after the top-left coordinate: a 9x9 square with a top-left corner of `3,5` is identified as `3,5,9`. For example: - For grid serial number `18`, the largest total square (with a total power of `113`) is 16x16 and has a top-left corner of `90,269`, so its identifier is `90,269,16`. - For grid serial number `42`, the largest total square (with a total power of `119`) is 12x12 and has a top-left corner of `232,251`, so its identifier is `232,251,12`. *What is the `X,Y,size` identifier of the square with the largest total power?*

A descriptions/Day12.md => descriptions/Day12.md +121 -0

@@ 0,0 1,121 @@\-\-- Day 12: Subterranean Sustainability \-\-- ----------------------------------------------- The year 518 is significantly more underground than your history books implied. Either that, or you\'ve arrived in a [vast cavern network]{title="It's probably this one. Can never be too sure, though."} under the North Pole. After exploring a little, you discover a long tunnel that contains a row of small pots as far as you can see to your left and right. A few of them contain plants - someone is trying to grow things in these geothermally-heated caves. The pots are numbered, with `0` in front of you. To the left, the pots are numbered `-1`, `-2`, `-3`, and so on; to the right, `1`, `2`, `3`\.... Your puzzle input contains a list of pots from `0` to the right and whether they do (`#`) or do not (`.`) currently contain a plant, the *initial state*. (No other pots currently contain plants.) For example, an initial state of `#..##....` indicates that pots `0`, `3`, and `4` currently contain plants. Your puzzle input also contains some notes you find on a nearby table: someone has been trying to figure out how these plants *spread* to nearby pots. Based on the notes, for each generation of plants, a given pot has or does not have a plant based on whether that pot (and the two pots on either side of it) had a plant in the last generation. These are written as `LLCRR => N`, where `L` are pots to the left, `C` is the current pot being considered, `R` are the pots to the right, and `N` is whether the current pot will have a plant in the next generation. For example: - A note like `..#.. => .` means that a pot that contains a plant but with no plants within two pots of it will not have a plant in it during the next generation. - A note like `##.## => .` means that an empty pot with two plants on each side of it will remain empty in the next generation. - A note like `.##.# => #` means that a pot has a plant in a given generation if, in the previous generation, there were plants in that pot, the one immediately to the left, and the one two pots to the right, but not in the ones immediately to the right and two to the left. It\'s not clear what these plants are for, but you\'re sure it\'s important, so you\'d like to make sure the current configuration of plants is sustainable by determining what will happen after *`20` generations*. For example, given the following input: initial state: #..#.#..##......###...### ...## => # ..#.. => # .#... => # .#.#. => # .#.## => # .##.. => # .#### => # #.#.# => # #.### => # ##.#. => # ##.## => # ###.. => # ###.# => # ####. => # For brevity, in this example, only the combinations which do produce a plant are listed. (Your input includes all possible combinations.) Then, the next 20 generations will look like this: 1 2 3 0 0 0 0 0: ...#..#.#..##......###...###........... 1: ...#...#....#.....#..#..#..#........... 2: ...##..##...##....#..#..#..##.......... 3: ..#.#...#..#.#....#..#..#...#.......... 4: ...#.#..#...#.#...#..#..##..##......... 5: ....#...##...#.#..#..#...#...#......... 6: ....##.#.#....#...#..##..##..##........ 7: ...#..###.#...##..#...#...#...#........ 8: ...#....##.#.#.#..##..##..##..##....... 9: ...##..#..#####....#...#...#...#....... 10: ..#.#..#...#.##....##..##..##..##...... 11: ...#...##...#.#...#.#...#...#...#...... 12: ...##.#.#....#.#...#.#..##..##..##..... 13: ..#..###.#....#.#...#....#...#...#..... 14: ..#....##.#....#.#..##...##..##..##.... 15: ..##..#..#.#....#....#..#.#...#...#.... 16: .#.#..#...#.#...##...#...#.#..##..##... 17: ..#...##...#.#.#.#...##...#....#...#... 18: ..##.#.#....#####.#.#.#...##...##..##.. 19: .#..###.#..#.#.#######.#.#.#..#.#...#.. 20: .#....##....#####...#######....#.#..##. The generation is shown along the left, where `0` is the initial state. The pot numbers are shown along the top, where `0` labels the center pot, negative-numbered pots extend to the left, and positive pots extend toward the right. Remember, the initial state begins at pot `0`, which is not the leftmost pot used in this example. After one generation, only seven plants remain. The one in pot `0` matched the rule looking for `..#..`, the one in pot `4` matched the rule looking for `.#.#.`, pot `9` matched `.##..`, and so on. In this example, after 20 generations, the pots shown as `#` contain plants, the furthest left of which is pot `-2`, and the furthest right of which is pot `34`. Adding up all the numbers of plant-containing pots after the 20th generation produces `325`. *After `20` generations, what is the sum of the numbers of all pots which contain a plant?* \-\-- Part Two \-\-- {#part2} -------------------- You realize that 20 generations aren\'t enough. After all, these plants will need to last another 1500 years to even reach your timeline, not to mention your future. *After fifty billion (`50000000000`) generations, what is the sum of the numbers of all pots which contain a plant?*

A descriptions/Day13.md => descriptions/Day13.md +247 -0

@@ 0,0 1,247 @@\-\-- Day 13: Mine Cart Madness \-\-- ------------------------------------- A crop of this size requires significant logistics to transport produce, soil, fertilizer, and so on. The Elves are very busy pushing things around in *carts* on some kind of rudimentary system of tracks they\'ve come up with. Seeing as how cart-and-track systems don\'t appear in recorded history for another 1000 years, the Elves seem to be making this up as they go along. They haven\'t even figured out how to avoid collisions yet. You map out the tracks (your puzzle input) and see where you can help. Tracks consist of straight paths (`|` and `-`), curves (`/` and `\`), and intersections (`+`). Curves connect exactly two perpendicular pieces of track; for example, this is a closed loop: /----\ | | | | \----/ Intersections occur when two perpendicular paths cross. At an intersection, a cart is capable of turning left, turning right, or continuing straight. Here are two loops connected by two intersections: /-----\ | | | /--+--\ | | | | \--+--/ | | | \-----/ Several *carts* are also on the tracks. Carts always face either up (`^`), down (`v`), left (`<`), or right (`>`). (On your initial map, the track under each cart is a straight path matching the direction the cart is facing.) Each time a cart has the option to turn (by arriving at any intersection), it turns *left* the first time, goes *straight* the second time, turns *right* the third time, and then repeats those directions starting again with *left* the fourth time, *straight* the fifth time, and so on. This process is independent of the particular intersection at which the cart has arrived - that is, the cart has no per-intersection memory. Carts all move at the same speed; they take turns moving a single step at a time. They do this based on their *current location*: carts on the top row move first (acting from left to right), then carts on the second row move (again from left to right), then carts on the third row, and so on. Once each cart has moved one step, the process repeats; each of these loops is called a *tick*. For example, suppose there are two carts on a straight track: | | | | | v | | | | | v v | | | | | v X | | ^ ^ | ^ ^ | | | | | | | | First, the top cart moves. It is facing down (`v`), so it moves down one square. Second, the bottom cart moves. It is facing up (`^`), so it moves up one square. Because all carts have moved, the first tick ends. Then, the process repeats, starting with the first cart. The first cart moves down, then the second cart moves up - right into the first cart, colliding with it! (The location of the crash is marked with an `X`.) This ends the second and last tick. Here is a longer example: /->-\ | | /----\ | /-+--+-\ | | | | | v | \-+-/ \-+--/ \------/ /-->\ | | /----\ | /-+--+-\ | | | | | | | \-+-/ \->--/ \------/ /---v | | /----\ | /-+--+-\ | | | | | | | \-+-/ \-+>-/ \------/ /---\ | v /----\ | /-+--+-\ | | | | | | | \-+-/ \-+->/ \------/ /---\ | | /----\ | /->--+-\ | | | | | | | \-+-/ \-+--^ \------/ /---\ | | /----\ | /-+>-+-\ | | | | | | ^ \-+-/ \-+--/ \------/ /---\ | | /----\ | /-+->+-\ ^ | | | | | | \-+-/ \-+--/ \------/ /---\ | | /----< | /-+-->-\ | | | | | | | \-+-/ \-+--/ \------/ /---\ | | /---<\ | /-+--+>\ | | | | | | | \-+-/ \-+--/ \------/ /---\ | | /--<-\ | /-+--+-v | | | | | | | \-+-/ \-+--/ \------/ /---\ | | /-<--\ | /-+--+-\ | | | | | v | \-+-/ \-+--/ \------/ /---\ | | /<---\ | /-+--+-\ | | | | | | | \-+-/ \-<--/ \------/ /---\ | | v----\ | /-+--+-\ | | | | | | | \-+-/ \<+--/ \------/ /---\ | | /----\ | /-+--v-\ | | | | | | | \-+-/ ^-+--/ \------/ /---\ | | /----\ | /-+--+-\ | | | | X | | \-+-/ \-+--/ \------/ After following their respective paths for a while, the carts eventually crash. To help prevent crashes, you\'d like to know *the location of the first crash*. Locations are given in `X,Y` coordinates, where the furthest left column is `X=0` and the furthest top row is `Y=0`: 111 0123456789012 0/---\ 1| | /----\ 2| /-+--+-\ | 3| | | X | | 4\-+-/ \-+--/ 5 \------/ In this example, the location of the first crash is `7,3`. \-\-- Part Two \-\-- {#part2} -------------------- There isn\'t much you can do to prevent crashes in this ridiculous system. However, by predicting the crashes, the Elves know where to be in advance and *instantly remove the two crashing carts* the moment any crash occurs. They can proceed like this for a while, but eventually, they\'re going to run out of carts. It could be useful to figure out where the last cart that *hasn\'t* crashed will end up. For example: />-<\ | | | /<+-\ | | | v \>+</ | | ^ \<->/ /---\ | | | v-+-\ | | | | \-+-/ | | | ^---^ /---\ | | | /-+-\ | v | | \-+-/ | ^ ^ \---/ /---\ | | | /-+-\ | | | | \-+-/ ^ | | \---/ After four very expensive crashes, a tick ends with only one cart remaining; its final location is `6,4`. *What is the location of the last cart* at the end of the first tick where it is the only cart left?