Well, I’m two days in and so far sticking to the plan. We continue in our attempt to hunt down Santa’s Chief Historian, but upon arriving at our fist location to inspect we’re presented with a new pressing problem to solve! The reactor that powers the North Pole is presenting engineers with some funky data. The data is in the form of multiple reports, each report listed across one line of a file the engineers have given you. Each report consists of a list of numbers called levels, which are space separated. The reactor engineers need to determine which reports are safe, the reactor can only tolerate levels that gradually are increasing, or gradually decreasing. A report is considered safe if both of the following statements are true:
Using the provided input file from the reactor engineers we need to determine how many reports in the overall file are safe.
Breaking this problem down, we have the following:
Breaking the problem down, we need to analyze each report (individual line in our input file) to determine if it’s safe, or not safe. Reviewing the challenge prompt, we can break down the problem into multiple smaller components:
Using the above allowed me to write a program to assist the engineers in quickly determining how many safe reports they had:
It worked! Our solution provided the engineers what they initially thought they were looking for. Only something didn’t look exactly right. The number of safe reports seemed low to them. Then an engineer realizes they forgot to tell us about the “Problem Dampener”. This dampener allows the reactor to tolerate a single bad level in what normally would be a safe report. It sounds like we may be able to keep some/most of our solution in problem 1 and just update it to account for the “Problem Dampener” while checking each report is safe or not but with updated parameters based on what the dampener allows.
Now, those of you who read my Day 1 post may notice a bit of a difference in today’s post. In the spirit of innovating and growing, I realized that in Day 1’s post, I really only walked through how I broke down the problem(s) into smaller more manageable sub-problems. Will there be further changes tomorrow? Maybe? All things considered, I’m enjoying these responses, it gives me something additional to time-block during the day, and so far keeping up with that, and writing a post haven’t been to onerous. Let’s see how I feel though as these problems get more difficult…
Two days down though, 23 to go!