Well, the real goal is for you to develop problem solving skills.
So, let me try to help you in this way.
First, it is a given that the algorithm does work, so the conclusion is that something in the way you have implemented it is not quite correct. Just because it works in one case, does not mean there are not errors that prevent it from working in ohters.
From my experience, when in this situation, it usually turns out that some assumption I have made is incorrect, and no matter how much I look at the code, I see nothing wrong. In this case it is helpful to step thru the code with different input or state values and watch the values I am computing.
Since you say it seems the code can never decrement, I would look at the possibility that certain computed values can not (or do not) go negative when they should. Set things up so that it should decrement, step thru the code and identify just why it never goes negative. You will find some reason for this.
This can sometimes be quite a struggle, but you must be willing to try, then try again, then try once more. You will find it if you keep at it.