2024(2): solve puzzle 1
This commit is contained in:
@ -26,15 +26,42 @@ The engineers are trying to figure out which reports are *safe*. The Red-Nosed r
|
||||
|
||||
In the example above, the reports can be found safe or unsafe by checking those rules:
|
||||
|
||||
`7 6 4 2 1`: *Safe* because the levels are all decreasing by `1` or `2`.
|
||||
`1 2 7 8 9`: *Unsafe* because `2 7` is an increase of `5`.
|
||||
`9 7 6 2 1`: *Unsafe* because `6 2` is a decrease of `4`.
|
||||
`1 3 2 4 5`: *Unsafe* because `1 3` is increasing but `3 2` is decreasing.
|
||||
`8 6 4 4 1`: *Unsafe* because `4 4` is neither an increase or a decrease.
|
||||
`1 3 6 7 9`: *Safe* because the levels are all increasing by `1`, `2`, or `3`.
|
||||
- `7 6 4 2 1`: *Safe* because the levels are all decreasing by `1` or `2`.
|
||||
- `1 2 7 8 9`: *Unsafe* because `2 7` is an increase of `5`.
|
||||
- `9 7 6 2 1`: *Unsafe* because `6 2` is a decrease of `4`.
|
||||
- `1 3 2 4 5`: *Unsafe* because `1 3` is increasing but `3 2` is decreasing.
|
||||
- `8 6 4 4 1`: *Unsafe* because `4 4` is neither an increase or a decrease.
|
||||
- `1 3 6 7 9`: *Safe* because the levels are all increasing by `1`, `2`, or `3`.
|
||||
|
||||
So, in this example, `2` reports are *safe*.
|
||||
|
||||
Analyze the unusual data from the engineers. *How many reports are safe?*
|
||||
|
||||
To begin, [get your puzzle input](input).
|
||||
|
||||
Your puzzle answer was `472`.
|
||||
|
||||
The first half of this puzzle is complete! It provides one gold star: *
|
||||
|
||||
--- Part Two ---
|
||||
|
||||
The engineers are surprised by the low number of safe reports until they realize they forgot to tell you about the Problem Dampener.
|
||||
|
||||
The Problem Dampener is a reactor-mounted module that lets the reactor safety systems *tolerate a single bad level* in what would otherwise be a safe report. It's like the bad level never happened!
|
||||
|
||||
Now, the same rules apply as before, except if removing a single level from an unsafe report would make it safe, the report instead counts as safe.
|
||||
|
||||
More of the above example's reports are now safe:
|
||||
|
||||
- `7 6 4 2 1`: `Safe` without removing any level.
|
||||
- `1 2 7 8 9`: `Unsafe` regardless of which level is removed.
|
||||
- `9 7 6 2 1`: `Unsafe` regardless of which level is removed.
|
||||
- `1 3 2 4 5`: `Safe` by removing the second level, `3`.
|
||||
- `8 6 4 4 1`: `Safe` by removing the third level, `4`.
|
||||
- `1 3 6 7 9`: `Safe` without removing any level.
|
||||
|
||||
Thanks to the Problem Dampener, `4` reports are actually *safe*!
|
||||
|
||||
Update your analysis by handling situations where the Problem Dampener can remove a single level from unsafe reports. *How many reports are now safe?*
|
||||
|
||||
Answer:
|
||||
|
||||
Reference in New Issue
Block a user