Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Samuel Fortunato20,229 Points
18:39 The algorithm works, but the teacher thinks it doesn't because the robot doesn't hug the left wall.
The algorithm at this point is like this:
if robot.canMoveForward = true move forward if robot.canMoveForward = false turn left if robot.canMoveForward = false turn left x2 if robot.canMoveForward = false turn left x3
This algorithm works to get the robot out of the maze. I've tried it. But, the teacher says it doesn't work because he seems too attached to the idea that the robot must hug the left wall at all times?
Is there any reason why he is correct? Seems dumb to me.
Steven Parker216,136 Points
Perhaps what he means is that the algorithm wouldn't work for solving every possible maze. It may solve the current maze, but if the exit were moved to the corridor that was being passed up, the robot would never escape.
The value of following the left wall is that it assures that all pathways will be investigated.