Post

Replies

Boosts

Views

Activity

Swift Playground - Round up the switches - character won't move
Trying to find an easy solution for the "Round up the switches" level. I think the while-loop is bugged - I have no explanation for the problem... var gemcount = 0 var switchcount = 0 func movement() {     moveForward()     if isBlocked && !isBlockedRight{         turnRight()     }     if isBlocked && !isBlockedLeft{         turnLeft()     } } func collect() {     if isOnGem {         collectGem()         gemcount = gemcount + 1}     } func toggle() {     if isOnClosedSwitch && switchcount != gemcount {         toggleSwitch()         switchcount = switchcount + 1} } while switchcount < gemcount {     movement()     collect()     toggle() }
6
0
1.9k
Jan ’23
Swift Playground - Round up the switches - character won't move
Trying to find an easy solution for the "Round up the switches" level. I think the while-loop is bugged - I have no explanation for the problem... var gemcount = 0 var switchcount = 0 func movement() {     moveForward()     if isBlocked && !isBlockedRight{         turnRight()     }     if isBlocked && !isBlockedLeft{         turnLeft()     } } func collect() {     if isOnGem {         collectGem()         gemcount = gemcount + 1}     } func toggle() {     if isOnClosedSwitch && switchcount != gemcount {         toggleSwitch()         switchcount = switchcount + 1} } while switchcount < gemcount {     movement()     collect()     toggle() }
Replies
6
Boosts
0
Views
1.9k
Activity
Jan ’23