There was recently a problem called Sanatorium. It is relatevely easy and a lot of people solved it. I don't know why, but with some problems I experience difficulties which a normal human should not ever encounter :)
I have a picture in mind which I want to share with you and I'd like to see how would you transform it into the code. Please, do not use your own interpretations (though I'd be glad to see them) of the problem. Do not use your own representations. Just use the following picture:
Each figure is a possible situation(state) for Vanya. We can enumerate all of the skewed rectangles with a pair of numbers (m, n). m — number of missed meals in day 0, n — number of skipped meals in day 5. The first rectangle is (0, 0), because we don't miss meals in the day 0 and we don't miss meals in day 5. Now the problem that I have is fitting (b, d, s) inside of these skewed rectangles. For example, if we are given (b = 6, d = 5, s = 5), we cannot use skewed rectangle (1, 0) (which located to the right of the very first rectangle), because it has x-1=5 breakfasts instead of required b = 6 meals in the morning. As I see it, the input (b = 6, d = 5, s = 5) splits all the possibilities (there are 9 of them) into 2 non-overlapping sets:
PossibleSet = {(0, 0), (0, 1), (0, 2)}
ImpossibleSet = {(1, 0), (2, 0), (1, 1), (2, 1), (1, 2), (2, 2)}
And we can check now the number of missed meals inside the PossibleSet: PossibleSet = {(6 - 6 + 6 - 5 + 6 - 5 = 2), (6 - 6 + 6 - 5 + 5 - 5 = 1), (6 - 6 + 5 - 5 + 5 - 5 = 0)}
So we can get the minimum number of missed meals 0 = min(2, 1, 0).
My brain refuses to produce the code out of these very thoughts.
Please, note that this is not the usual ask for help of how to solve the problem. This isn't merely about solving the problem. This one is about thinking process and it's correction.
I'd be glad to see the transformation steps (as detailed as possible). How does this picture smoothly translates into code (not just the final solution — there are plenty of those already). Maybe it will help me bridge some psycological gap that I currently have in my brain.