My while loop continues execution after reaching gemsCollected = 3 if I use OR logical operator (||) and stops execution if I use AND logical operator (&&). IMHO it should be the other way around, right?
var gemsCollected = 0
var switchesToggled = 0
while gemsCollected < 3 || switchesToggled < 4 {
moveForward()
if gemsCollected < 3 && isOnGem {
collectGem()
gemsCollected = gemsCollected + 1
} else if switchesToggled < 4 && isOnClosedSwitch {
toggleSwitch()
switchesToggled = switchesToggled + 1
} else if isBlocked && !isBlockedRight {
turnRight()
} else if isBlocked && !isBlockedLeft {
turnLeft()
}
}