playground 设定正确的传送门
swift吧
全部回复
仅看楼主
level 1
庾玲玲0I0 楼主
moveForward( ) 方法放while的最前可能更好,没高兴确认具体的执行步数
2018年09月06日 03点09分 1
level 1
var gemCounter = 0
while gemCounter < 4 {
moveForward()
if isBlocked && isOnGem {
bluePortal.isActive = false
collectGem()
gemCounter += 1
turnLeft()
turnLeft()
}else if isOnGem && !isBlocked {
bluePortal.isActive = true
collectGem()
gemCounter += 1
turnRight()
turnRight()
}else if isBlocked {
turnRight()
turnRight()
pinkPortal.isActive = false
}
}
2021年04月11日 18点04分 4
1