Originally Posted by
juanjuanjuan
Sorry, I didn't understand everything. You say that, in a for, I have to write 2 if.
If (continue with the steps)
If (stop because I finish the "square")
Are you saying that? I'm trying to write a program that says that but I can't
You can use either a for or a while or a do while loop. They all can be made to work in place of the other. I like the for loop for this one.
You turn right on square one, and enter the loop.
Code:
start the loop: (stop the loop when you have no more empty squares) {
You walk straight ahead.
(either the end of the array has been reached, or the square in front of you has a "been visited" value in it)
If (you can't walk in that direction any more, && you have an empty square on your right)
You turn right
}
Give it some work, Juan!
Isn't that a thing of simple "noir" genre beauty?