News
Days 14 and 15 (Hints)
Written on 15.12.2022 09:46 by Sven Rahmann
Good morning,
fortunately, ChatGPT has some inspiration for us:
What would a wise woman do if she could not solve a problem immediately?
A wise woman, like a wise man, would likely take a step back and approach the problem from a different perspective if she couldn't solve it immediately. She might seek out additional information or resources to help her understand the problem better, or she might consult with others to get their input and advice. In any case, a wise woman would likely recognize that sometimes the best course of action is to take a break and come back to the problem later with a fresh perspective.
Day 14 is, in my personal opinion, one of the nicest problems so far. It is a simple physical model and can be implemented in a relatively straightforward way. You may wonder which data structure you should use to represent the (x,y) points. I recommend a dict (called "cave"), so you do not need to know the maximum and minimum x and y values beforehand. When a pair (x,y) is not a key in the dict, there is just air at (x,y). If there is a wall or sand, the corresponding symbol will be at cave[x,y]. For the second part, note that the new wall does not really have to be infinite. You can also not insert any new wall at all, but special-check the y coordinate.
Day 15 (today) can be a bit tricky. For part 1, carefully look at the example; why is the answer to the toy problem 26 and not 27? While part 1 can be solved by examining each position in the y-row, part 2 is on a much larger scale, so you'll need something much more efficient than working with single positions: In each row, each sensor covers a whole interval in the given limited range. The intervals of different sensors may overlap.