Help with 2021 bronze #3: Walking home

I am stuck on this 2021 bronze problem, so can someone please give me some ideas as to where I should start, the appropriate algorithm, and how to implement it? Thanks!
Problem Link here:

Hi there! This is a good problem! I have a hint for you on where to start! Notice that K is in the range from 1 to 3 inclusive. Now, let’s think about all the possible paths when there are no haybales. When K = 1, there are only 2 possible paths - when you go directly down and then to the right or when you go to the right and then down. When K = 2, I believe that the number of possible paths is 2*N - 4. When K = 3, the number of paths is the same as when K = 2. I know I have only helped you with part of the problem, because you need to still deal with the haybales. I advise you to make examples on paper with small numbers to test out all the possible paths - I can assure you that using small numbers like N = 3 or N = 4 will help you find all possible paths. Here, I have only given you a formula, but you still need to know all the paths yourself so that you can check on code if those paths have haybales! Also, please double-check my formulas! I might be wrong. Finally, when working out examples on paper, you don’t need to use haybales! Just make a grid and make as many paths as possible from the top-left to bottom-right for each value of K. Good luck!

1 Like

Thanks a lot @aU1a ! :grin:
I will try the implementation and let u know how it goes