Last active
October 23, 2016 16:52
-
-
Save imbradmiller/ed818738fbdca3ece7bcce3c8aab62c7 to your computer and use it in GitHub Desktop.
It Takes Two Long Form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
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
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.