-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,71 @@ | ||
# Answers | ||
|
||
| Part 1 | Part 2 | | ||
| --------- | ---------- | | ||
| ` ` | ` ` | | ||
| Part 1 | Part 2 | | ||
| -------- | ----------------- | | ||
| `193899` | `229682160383225` | | ||
|
||
## --- Day 11: Plutonian Pebbles --- | ||
|
||
The ancient civilization on [Pluto](https://adventofcode.com/2019/day/20) was known for its ability to manipulate spacetime, and while The Historians explore their infinite corridors, you've noticed a strange set of physics-defying stones. | ||
|
||
At first glance, they seem like normal stones: they're arranged in a perfectly _straight line_, and each stone has a _number_ engraved on it. | ||
|
||
The strange part is that every time you blink, the stones _change_. | ||
|
||
Sometimes, the number engraved on a stone changes. Other times, a stone might _split in two_, causing all the other stones to shift over a bit to make room in their perfectly straight line. | ||
|
||
As you observe them for a while, you find that the stones have a consistent behavior. Every time you blink, the stones each _simultaneously_ change according to the _first applicable rule_ in this list: | ||
|
||
* If the stone is engraved with the number `0`, it is replaced by a stone engraved with the number `1`. | ||
* If the stone is engraved with a number that has an _even_ number of digits, it is replaced by _two stones_. The left half of the digits are engraved on the new left stone, and the right half of the digits are engraved on the new right stone. (The new numbers don't keep extra leading zeroes: `1000` would become stones `10` and `0`.) | ||
* If none of the other rules apply, the stone is replaced by a new stone; the old stone's number _multiplied by 2024_ is engraved on the new stone. | ||
|
||
No matter how the stones change, their _order is preserved_, and they stay on their perfectly straight line. | ||
|
||
How will the stones evolve if you keep blinking at them? You take a note of the number engraved on each stone in the line (your puzzle input). | ||
|
||
If you have an arrangement of five stones engraved with the numbers `0 1 10 99 999` and you blink once, the stones transform as follows: | ||
|
||
* The first stone, `0`, becomes a stone marked `1`. | ||
* The second stone, `1`, is multiplied by 2024 to become `2024`. | ||
* The third stone, `10`, is split into a stone marked `1` followed by a stone marked `0`. | ||
* The fourth stone, `99`, is split into two stones marked `9`. | ||
* The fifth stone, `999`, is replaced by a stone marked `2021976`. | ||
|
||
So, after blinking once, your five stones would become an arrangement of seven stones engraved with the numbers `1 2024 1 0 9 9 2021976`. | ||
|
||
Here is a longer example: | ||
|
||
Initial arrangement: | ||
125 17 | ||
|
||
After 1 blink: | ||
253000 1 7 | ||
|
||
After 2 blinks: | ||
253 0 2024 14168 | ||
|
||
After 3 blinks: | ||
512072 1 20 24 28676032 | ||
|
||
After 4 blinks: | ||
512 72 2024 2 0 2 4 2867 6032 | ||
|
||
After 5 blinks: | ||
1036288 7 2 20 24 4048 1 4048 8096 28 67 60 32 | ||
|
||
After 6 blinks: | ||
2097446912 14168 4048 2 0 2 4 40 48 2024 40 48 80 96 2 8 6 7 6 0 3 2 | ||
|
||
|
||
In this example, after blinking six times, you would have `22` stones. After blinking 25 times, you would have _`55312`_ stones! | ||
|
||
Consider the arrangement of stones in front of you. _How many stones will you have after blinking 25 times?_ | ||
|
||
----------------- | ||
|
||
## --- Part Two --- | ||
|
||
The Historians sure are taking a long time. To be fair, the infinite corridors _are_ very large. | ||
|
||
_How many stones would you have after blinking a total of 75 times?_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,58 @@ | ||
# Answers | ||
|
||
| Part 1 | Part 2 | | ||
| --------- | ---------- | | ||
| ` ` | ` ` | | ||
| Part 1 | Part 2 | | ||
| ---------------- | ----------------- | | ||
| `10741443549536` | `500335179214836` | | ||
|
||
## --- Day 7: Bridge Repair --- | ||
|
||
The Historians take you to a familiar [rope bridge](https://adventofcode.com/2022/day/9) over a river in the middle of a jungle. The Chief isn't on this side of the bridge, though; maybe he's on the other side? | ||
|
||
When you go to cross the bridge, you notice a group of engineers trying to repair it. (Apparently, it breaks pretty frequently.) You won't be able to cross until it's fixed. | ||
|
||
You ask how long it'll take; the engineers tell you that it only needs final calibrations, but some young elephants were playing nearby and _stole all the operators_ from their calibration equations! They could finish the calibrations if only someone could determine which test values could possibly be produced by placing any combination of operators into their calibration equations (your puzzle input). | ||
|
||
For example: | ||
|
||
190: 10 19 | ||
3267: 81 40 27 | ||
83: 17 5 | ||
156: 15 6 | ||
7290: 6 8 6 15 | ||
161011: 16 10 13 | ||
192: 17 8 14 | ||
21037: 9 7 18 13 | ||
292: 11 6 16 20 | ||
|
||
|
||
Each line represents a single equation. The test value appears before the colon on each line; it is your job to determine whether the remaining numbers can be combined with operators to produce the test value. | ||
|
||
Operators are _always evaluated left-to-right_, _not_ according to precedence rules. Furthermore, numbers in the equations cannot be rearranged. Glancing into the jungle, you can see elephants holding two different types of operators: _add_ (`+`) and _multiply_ (`*`). | ||
|
||
Only three of the above equations can be made true by inserting operators: | ||
|
||
* `190: 10 19` has only one position that accepts an operator: between `10` and `19`. Choosing `+` would give `29`, but choosing `*` would give the test value (`10 * 19 = 190`). | ||
* `3267: 81 40 27` has two positions for operators. Of the four possible configurations of the operators, _two_ cause the right side to match the test value: `81 + 40 * 27` and `81 * 40 + 27` both equal `3267` (when evaluated left-to-right)! | ||
* `292: 11 6 16 20` can be solved in exactly one way: `11 + 6 * 16 + 20`. | ||
|
||
The engineers just need the _total calibration result_, which is the sum of the test values from just the equations that could possibly be true. In the above example, the sum of the test values for the three equations listed above is _`3749`_. | ||
|
||
Determine which equations could possibly be true. _What is their total calibration result?_ | ||
|
||
----------------- | ||
|
||
## --- Part Two --- | ||
|
||
The engineers seem concerned; the total calibration result you gave them is nowhere close to being within safety tolerances. Just then, you spot your mistake: some well-hidden elephants are holding a _third type of operator_. | ||
|
||
The [concatenation](https://en.wikipedia.org/wiki/Concatenation) operator (`||`) combines the digits from its left and right inputs into a single number. For example, `12 || 345` would become `12345`. All operators are still evaluated left-to-right. | ||
|
||
Now, apart from the three equations that could be made true using only addition and multiplication, the above example has three more equations that can be made true by inserting operators: | ||
|
||
* `156: 15 6` can be made true through a single concatenation: `15 || 6 = 156`. | ||
* `7290: 6 8 6 15` can be made true using `6 * 8 || 6 * 15`. | ||
* `192: 17 8 14` can be made true using `17 || 8 + 14`. | ||
|
||
Adding up all six test values (the three that could be made before using only `+` and `*` plus the new three that can now be made by also using `||`) produces the new _total calibration result_ of _`11387`_. | ||
|
||
Using your new knowledge of elephant hiding spots, determine which equations could possibly be true. _What is their total calibration result?_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters