Swift Playground Learn to Code 1 Answers

Disclosure: Some of the links below are affiliate links, meaning, at no additional cost to you, I will earn a commission if you click through and make a purchase. As an Amazon Associate I also earn from qualifying purchases.

Issuing Commands

Beginner solution

moveForward()
moveForward()
moveForward()
collectGem()

Advanced solution

while !isOnGem {
moveForward()
}
collectGem()

Adding a New Command

Beginner solution

moveForward()
moveForward()
turnLeft()
moveForward()
moveForward()
collectGem()

Advanced solution

while !isOnGem {
if isBlocked {
turnLeft()
}
moveForward()
}
collectGem()

Leave a Comment

Your email address will not be published.