Good code is its own best documentation. As you're about to add a comment, ask yourself, 'How can I improve the code so that this comment isn't needed?' Improve the code and then document it to make it even clearer. Steve McConnell

Rat in a Maze

Language Java | Level Intermediate | Category Algorithms | August 3, 2015 10:03 pm


Algorithm Problem Description

A Maze is given matrix and Rat start from upper left and should reach to lower right. The Rat starts from source to destination and moves only forward and down direction.

Given a maze, 4 x 4 matrix. A rat has to find a path from source to destination. Rat start from left top corner and go to right bottom destination. There are few cells which are dead end which means rat can­not enter into those cells.

Write a program to rat start from source to destination?

Output

          	        
          	        

Arrays for Maze1 : [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 0, 1, 1]]
 1 0 1 1 1
 1 1 1 0 1
 0 0 0 1 1
 0 0 0 1 0
 0 0 0 1 1
Arrays for Maze2 : [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]
NO PATH FOUND

          	        
          	        				    


Comments



Please login to add comments.