Question: Please code this question without using arrays and clearly explain algorithms. Note : Do NOT use arrays to solve this question. Question: A mouse has
Please code this question without using arrays and clearly explain algorithms.
Note: Do NOT use arrays to solve this question.
Question: A mouse has to find its way through a maze to find its reward, a piece of cheese. Represent this maze by a matrix of size MNMN made of '1' (walls) and '0' (paths). The mouse must always enter the maze from the first column in the first row and exit from the last row (any appropriate column). It must step on only zeroes while in the maze. If no such path (path of '0's) exists through the maze, the mouse will go hungry. To make this problem simple, let's assume that the mouse can only move from left to right and from top to bottom in the maze. So, your algorithm's goal should be to keep moving left to right along a row until you hit a 1, and then try to go to the row below. If you can go to the row below, you again start moving along the new row until you hit a 1. Keep repeating the procedure until you reach the last row. If you can't, you don't go back and look for a different entry. You just say there is no path (By Printing ANGRY MOUSE) and exit (no input read after that). You need to go as right as possible in the last row just like other rows, in case you can reach the last row. Basic movement rule: don't move to a new row unless you can no longer proceed on the current row.
INPUT FORMAT: Single line containing two integers MM, NN Followed by MNMN grid made of '1' and '0'. Top left will always be '0'.
OUTPUT FORMAT: You have to output the exit point of each row (integer) on a separate line. If no entry is possible in a row (path does not exist) print "ANGRY MOUSE".

EXAMPLES: Output 011 001 3 6 001111 100011 111001 4 001 010 ANGRY MOUSE 1100011 II Row 0 111 01 1 1 // Row 1-for this row, store 4 as end of path on the Row 0 1. After every Line take an extra input to ensure correct input is read. 2. Column Number Starts from 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
