Last active
August 29, 2015 14:05
-
-
Save cennydavidsson/056aca15d49bb7ad1ea6 to your computer and use it in GitHub Desktop.
First attempt to rewrite some of the Solution codebase to swift.
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
| func validInput(input:String) -> Bool { | |
| var last = "" | |
| if let x = equation.last { last = x } | |
| switch last { | |
| case "+", "-", "*", "(", "": | |
| switch input { | |
| case let x where input.toInt() != nil: | |
| return true | |
| case "(": | |
| return true | |
| default: | |
| return false | |
| } | |
| case let x where last.toInt() != nil: | |
| switch input { | |
| case "+", "-", "*", ")" where parenthesesStack > 0: | |
| return true | |
| default: | |
| return false | |
| } | |
| case ")": | |
| switch input { | |
| case "+", "-", "*", "(", ")": | |
| return true | |
| default: | |
| return false | |
| } | |
| default: | |
| return false | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment