Created
February 5, 2022 18:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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