PlayGround/코딩배우기 2
PlayGrounds [ 동일한 값 확인하기 ]
동빠기
2020. 2. 27. 17:29

let switchCounter = numberOfSwitches
//1. 수집한 보석의 개수를 기록하기 위해 변수를 선언합니다.
var gemCounter = 0
//2. 보석을 세는 변수의 값과 switchCounter를 비교하여 보석 수집을 중단할 시기를 결정합니다.
while gemCounter != switchCounter {
while !isBlocked {
if isOnGem{
collectGem()
gemCounter += 1
}
moveForward()
}
turnRight()
}