Skip to content

Instantly share code, notes, and snippets.

@imbradmiller
Created October 22, 2016 17:33
Show Gist options
  • Save imbradmiller/e47115c8ae153ae6557cf2477d4719a6 to your computer and use it in GitHub Desktop.
Save imbradmiller/e47115c8ae153ae6557cf2477d4719a6 to your computer and use it in GitHub Desktop.
Train Your Expert
let expert = Expert()
var gemCon = 0
var steps = 0
func blocked() {
if !expert.isBlockedRight {
expert.turnRight()
} else if expert.isBlocked {
expert.turnLeft()
expert.turnLeft()
}
}
func gemCollector() {
if expert.isOnGem {
expert.collectGem()
gemCon += 1
}
}
func stepCounter(){
steps += 1
}
while gemCon != 6 {
stepCounter()
expert.moveForward()
gemCollector()
if steps == 10 {
expert.turnLockDown()
}
blocked()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment