I think this is the answer. I've checked it already. it works!
while !isOnOpenSwitch {
moveForward()
if isBlocked && isBlockedRight {
turnLeft()
}
if isBlocked && isBlockedLeft {
turnRight()
}
if isBlocked && !isBlockedRight {
turnLeft()
}
while isOnGem {
collectGem()
}
while isOnClosedSwitch {
toggleSwitch()
moveForward()
}
}
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
Tags: