Skip to content

Instantly share code, notes, and snippets.

@aenakin
Created February 5, 2022 18:45
Show Gist options
  • Save aenakin/26e6723bef51992ccdd65bf3f7008ed9 to your computer and use it in GitHub Desktop.
Save aenakin/26e6723bef51992ccdd65bf3f7008ed9 to your computer and use it in GitHub Desktop.
My take on the final level of Playgrounds Learn to Code 1 - Roll Right Roll Left.
func navAround() {
if !isBlocked {
while isOnGem || isOnClosedSwitch {
if isOnGem {
collectGem()
} else if isOnClosedSwitch {
toggleSwitch()
}
}
moveForward()
} else if isBlockedLeft && isBlocked {
turnRight()
} else {
turnLeft()
}
}
while !isOnOpenSwitch {
navAround()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment