build a program, something similar to a maze algorithm

This is a discussion on build a program, something similar to a maze algorithm within the C Programming forums, part of the General Programming Boards category; i have this "test" let's say.. i need to solve this problem, it's not homework but i need it in ...

build a program, something similar to a maze algorithm

i have this "test" let's say.. i need to solve this problem, it's not homework but i need it in order to pass a test.I could need a little help, because i don't understand what i need to do. I need the algorithm here! So it goes: The table below represents a labyrinth. "1" means you cannot pass through that value, "0" means you can pass through that value. "T" is the treasure to achieve and "H" is the entrance. The coordinates are : H(3.1) , T(2.8).-I need a program that reads a matrix A[1..M,1..N] which itself represents a labyrinth with elements [0,1] and also reads the H,T value.It should print a way to the treasure , if there is one, else it should say "No way to the treasure"he Matrix is:

Code:

11111111111100010 T 01
H 00111011111000000011111111111

I got some pseudocode with someone's help

Code:

var walkingDirection = up;
while (not at target)
if (next field in walkingDirection is not a wall)
go to next field in walkingDirection
else
turn right
end if
end while

The pseudocode you provide is for an algorithm which will not always find the target. E.g. for:

Code:

111111111
100000001
101011101
H0101T001
101011101
100000001
111111111

Also, given it states to loop while not at target, that's going to produce an infinite loop. Not to mention that for the cases where there is no way to the target that will also obviously be an infinite loop.

There are plenty of maze solving algorithms described on the net. Hop on to your favourite search engine and get searching for something that will actually work.