Skip to content

Instantly share code, notes, and snippets.

@imbradmiller
Last active March 11, 2020 06:47
Show Gist options
  • Save imbradmiller/ce1cc5d47b7cf65137b970354409a4a1 to your computer and use it in GitHub Desktop.
Save imbradmiller/ce1cc5d47b7cf65137b970354409a4a1 to your computer and use it in GitHub Desktop.
Seeking Seven Gems
var gemCollector = 0
while gemCollector < 7 {
moveForward()
if isBlocked {
turnLeft()
turnLeft()
moveForward()
else if isOnGem() {
collectGem()
gemCollector = gemCollector +1
}
}
}
@BarathPA
Copy link

difference between your code and this code, please:

var gemCounter = 0
while gemCounter < 7 {
moveForward()
if isOnGem {
collectGem()
gemCounter = gemCounter + 1
}
if isBlocked {
turnLeft()
turnLeft()
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment