Hi, I'm new to the Swift language but I've found the learning process to be quite enjoyable thus far. I have, however, been stumped by one of the "lessons". It is Swift Playgrounds > Learn to Code 1 > Algorithms > Which Way to Turn?
Here is the code I have used:
func navigatethemaze() {
if isBlocked && !isBlockedRight {
turnRight()
moveForward()
}
if isBlocked && !isBlockedLeft {
turnLeft()
moveForward()
}
if isBlockedRight && !isBlocked || isBlockedLeft && !isBlocked {
moveForward()
}
}
while !isonGem {
while! isOnClosedSwitch {
navigatethemaze()
}
if !isBlocked {
toggleSwitch()
turnRight()
moveForward()
} else {
toggleSwitch()
turnLeft()
}
}
collectGem()
Again, any help whatsoever is appreciated. Thank You.