This is special kind of maze where some of the cells are associated with some cost. So,this code will give the path which is cheapest. In input.txt source(x) source(y) destination(x) destination(y) size of matrix M N then the matrix 1 is for no cost cell 2 is for costly cell (same cost for all) 0 are the boundries tHaNk yOu