|
| 1 | +--- Day 2: Red-Nosed Reports --- |
| 2 | + |
| 3 | + Fortunately, the first location The Historians want to search isn't a |
| 4 | + long walk from the Chief Historian's office. |
| 5 | + |
| 6 | + While the [1]Red-Nosed Reindeer nuclear fusion/fission plant appears to |
| 7 | + contain no sign of the Chief Historian, the engineers there run up to |
| 8 | + you as soon as they see you. Apparently, they still talk about the time |
| 9 | + Rudolph was saved through molecular synthesis from a single electron. |
| 10 | + |
| 11 | + They're quick to add that - since you're already here - they'd really |
| 12 | + appreciate your help analyzing some unusual data from the Red-Nosed |
| 13 | + reactor. You turn to check if The Historians are waiting for you, but |
| 14 | + they seem to have already divided into groups that are currently |
| 15 | + searching every corner of the facility. You offer to help with the |
| 16 | + unusual data. |
| 17 | + |
| 18 | + The unusual data (your puzzle input) consists of many reports , one |
| 19 | + report per line. Each report is a list of numbers called levels that |
| 20 | + are separated by spaces. For example: |
| 21 | + |
| 22 | + 7 6 4 2 1 |
| 23 | +1 2 7 8 9 |
| 24 | +9 7 6 2 1 |
| 25 | +1 3 2 4 5 |
| 26 | +8 6 4 4 1 |
| 27 | +1 3 6 7 9 |
| 28 | + |
| 29 | + |
| 30 | + This example data contains six reports each containing five levels. |
| 31 | + |
| 32 | + The engineers are trying to figure out which reports are safe . The |
| 33 | + Red-Nosed reactor safety systems can only tolerate levels that are |
| 34 | + either gradually increasing or gradually decreasing. So, a report only |
| 35 | + counts as safe if both of the following are true: |
| 36 | + * The levels are either all increasing or all decreasing . |
| 37 | + * Any two adjacent levels differ by at least one and at most three . |
| 38 | + |
| 39 | + In the example above, the reports can be found safe or unsafe by |
| 40 | + checking those rules: |
| 41 | + * 7 6 4 2 1 : Safe because the levels are all decreasing by 1 or 2. |
| 42 | + * 1 2 7 8 9 : Unsafe because 2 7 is an increase of 5. |
| 43 | + * 9 7 6 2 1 : Unsafe because 6 2 is a decrease of 4. |
| 44 | + * 1 3 2 4 5 : Unsafe because 1 3 is increasing but 3 2 is decreasing. |
| 45 | + * 8 6 4 4 1 : Unsafe because 4 4 is neither an increase or a |
| 46 | + decrease. |
| 47 | + * 1 3 6 7 9 : Safe because the levels are all increasing by 1, 2, or |
| 48 | + 3. |
| 49 | + |
| 50 | + So, in this example, 2 reports are safe . |
| 51 | + |
| 52 | + Analyze the unusual data from the engineers. How many reports are safe? |
| 53 | + |
| 54 | +--- Part Two --- |
| 55 | + |
| 56 | + The engineers are surprised by the low number of safe reports until |
| 57 | + they realize they forgot to tell you about the Problem Dampener . |
| 58 | + |
| 59 | + The Problem Dampener is a reactor-mounted module that lets the reactor |
| 60 | + safety systems tolerate a single bad level in what would otherwise be a |
| 61 | + safe report. It's like the bad level never happened! |
| 62 | + |
| 63 | + Now, the same rules apply as before, except if removing a single level |
| 64 | + from an unsafe report would make it safe, the report instead counts as |
| 65 | + safe. |
| 66 | + |
| 67 | + More of the above example's reports are now safe: |
| 68 | + * 7 6 4 2 1 : Safe without removing any level. |
| 69 | + * 1 2 7 8 9 : Unsafe regardless of which level is removed. |
| 70 | + * 9 7 6 2 1 : Unsafe regardless of which level is removed. |
| 71 | + * 1 3 2 4 5 : Safe by removing the second level, 3 . |
| 72 | + * 8 6 4 4 1 : Safe by removing the third level, 4 . |
| 73 | + * 1 3 6 7 9 : Safe without removing any level. |
| 74 | + |
| 75 | + Thanks to the Problem Dampener, 4 reports are actually safe ! |
| 76 | + |
| 77 | + Update your analysis by handling situations where the Problem Dampener |
| 78 | + can remove a single level from unsafe reports. How many reports are now |
| 79 | + safe? |
| 80 | + |
| 81 | +References |
| 82 | + |
| 83 | + 1. file:///2015/day/19 |
0 commit comments