Created
July 8, 2013 21:25
-
-
Save cdeszaq/5952644 to your computer and use it in GitHub Desktop.
This file contains 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
// isPalindrome - ignore cases, spaces and punctuation | |
// Empty string is false | |
// O(1) space, cant modify original string | |
[1,2,3,4,5,6].each { | |
println "Running isPalindrome${it}" | |
assert !"isPalindrome${it}"("") // False | |
assert !"isPalindrome${it}"(" !,! ") // False | |
assert "isPalindrome${it}"("M") // True | |
assert "isPalindrome${it}"("MM..M") // True | |
assert "isPalindrome${it}"("Madam! I'm... Adam!!!!!") // True | |
} | |
// Assume you have this method available | |
def isAlphaNumeric(c) { | |
c ==~ "[A-Za-z0-9]" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment