Post

Replies

Boosts

Views

Activity

Reply to Swift Playground - Round up the switches - character won't move
var switchCounter = 0 var gemCounter = 0 for i in 1 ... 3 { moveForward() if isOnGem { collectGem() gemCounter += 1 } } while switchCounter < gemCounter{ if isOnGem { collectGem() gemCounter += 1 } else if isOnClosedSwitch { toggleSwitch() switchCounter += 1 }else if isBlocked { turnRight() } moveForward() } WORKED , still open to inprovment
Replies
Boosts
Views
Activity
Feb ’24
Reply to Swift Playground - Round up the switches - character won't move
start the loof by using a for i in 1 ... 3 { moveForward() if isOnGem { collectGem() gemCounter += 1 } it cretats a difference in the initial steps
Replies
Boosts
Views
Activity
Feb ’24