# Thread: build a program, something similar to a maze algorithm

1. ## 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:
```1 1 1 1 1 1 1 1 1 1
1 1 0 0 0 1 0 T 0 1
H 0 0 1 1 1 0 1 1 1
1 1 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1```
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 ```

2. > i need to solve this problem, it's not homework but i need it in order to pass a test.
I see a bright future in politics for you, with your apparent ease at redefining words on the fly.

You're hoping to exchange academic effort (or someone's at any rate) in reward for academic credit (marks, pass, grades etc).
To me, that's homework.

Code:
```1 1 1 1 1 1 1 1 1 1
1 1 0 0 0 1 0 T 0 1
H 0 0 1 1 1 0 1 1 1
1 1 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1```
Think about what happens when you get to 0
Think about what happens when you get to 0

3. 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.