Skip to content

Instantly share code, notes, and snippets.

@imbradmiller
Last active October 23, 2016 16:52
Show Gist options
  • Save imbradmiller/ed818738fbdca3ece7bcce3c8aab62c7 to your computer and use it in GitHub Desktop.
Save imbradmiller/ed818738fbdca3ece7bcce3c8aab62c7 to your computer and use it in GitHub Desktop.
It Takes Two Long Form
let expert = Expert()
let character = Character()
var gemCon = 0
var switchCon = 0
func expertNav() {
expert.turnLeft()
expert.moveForward()
expert.moveForward()
expert.moveForward()
expert.turnRight()
expert.moveForward()
expert.moveForward()
expert.turnLeft()
expert.turnLockDown()
expert.turnLockDown()
expert.turnRight()
expert.moveForward()
expert.moveForward()
expert.turnRight()
expert.moveForward()
expert.moveForward()
expert.moveForward()
expert.moveForward()
expert.moveForward()
expert.moveForward()
expert.turnRight()
expert.moveForward()
expert.moveForward()
expert.turnLeft()
expert.turnLockUp()
}
func characterNav() {
character.moveForward()
character.moveForward()
if character.isOnGem {
character.collectGem()
gemCon += 1
character.moveForward()
character.moveForward()
}
if character.isOnClosedSwitch {
character.toggleSwitch()
switchCon += 1
}
}
while gemCon < 1 && switchCon < 1 {
expertNav()
characterNav()
}
@imbradmiller
Copy link
Author

I wrote this in longer form. I feel like I can improve it by counting the expert instance's steps. Going to give that a whirl here.

@imbradmiller
Copy link
Author

Essentially reducing the lines of code necessary for completing the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment