Actually it was meant to be canFindPath (I changed name). I'm making recursive calls to itself.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35256
7
posted
0
If any of the recursive calls ever return "true", then you should not recurse any further, but return straight back up the call stack. As it is, you're ignoring the returned value, and continue to look for solutions in other directions.
David Delgado
Greenhorn
Joined: Sep 19, 2010
Posts: 6
posted
0
Thank you for replying. So then I need to put if statements inside my check N/W/S/E loops to check if the program returned true?? That's what I was thinking of earlier this morning but wasn't sure. Should I use a local variable to keep track of the boolean?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35256
7
posted
0
The easiest may be to replace "canFindPath(...)" by "if (canFindPath(...)) return true" or something like that.
David Delgado
Greenhorn
Joined: Sep 19, 2010
Posts: 6
posted
0
Thank you Uff, that solved my problem.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
3
Don't go and edit your first post
Now people who read this thread can't understand what the question was about, and the replies all read as nonsense.