I’m new to Swift and I’m using Playgrounds to learn. When I solve a puzzle I often feel like my solution was sloppy or inefficient. Is there a better place to post my code for feedback? I figured I would start here and take suggestions greatfully. Thanks in advance! Below is my solution for Learning to Code 2, Types, Setting the Right Portal. I feel like it could be better...
var gemCounter = 0
pinkPortal.isActive = false
func collectRoutine() {
collectGem()
gemCounter += 1
bluePortal.isActive = false
}
func navigatePart1 () {
while gemCounter < 2 {
moveForward()
if isBlocked {
turnLeft()
turnLeft()
}
if isOnGem {
collectRoutine()
}
}
}
func navigatePart2 () {
while gemCounter < 4 {
moveForward()
if isBlocked {
turnLeft()
turnLeft()
}
if isOnGem {
collectGem()
gemCounter += 1
}
if gemCounter == 3 {
pinkPortal.isActive = true
}
}
}
navigatePart1()
bluePortal.isActive = true
navigatePart2()