Rat chases its cheese

Testcase 5 is not passing but rest other does.Where i am dong wrong

Hi @yashomar95,
There are some error in the code please check the comments.
i have corrected them

I am not getting what the choice variiable does? For the infinite loop so that it does not get back to those cells from which it has come, I had added the conditions already

Yes you are correct but there was a testcase which was having the problem of no path found when there was a path available so just to be safe i added this choice variable and then tweaked other errors. If you think you can do this without choice variable then go ahead you will get correct answer. I just added to be safe anyways.

I want to know the logic behind the value of choice. How it is working?