Created
June 10, 2018 16:07
-
-
Save rjlutz/68fdfee69bc9bfafd7fb4120713d6ee4 to your computer and use it in GitHub Desktop.
template for porting Palindrome.java to dart
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
// refer to the Java code here: | |
// https://gist.github.com/rjlutz/3c26a1be877529de8dd28049d12415d0 | |
// complete the dart implementation below to have the same functionality | |
class Palindrome { | |
// TODO implement check | |
static check(String s) { | |
return true; | |
} | |
} | |
// lambda to mimic Java's Character.isLetterOrDigit() | |
bool isLetterOrDigit(String s, int idx) => s[idx].contains(RegExp(r'[\da-zA-Z]')); | |
main() { | |
// should result in true,false,true,false,true,false | |
print(Palindrome.check('radar')); | |
print(Palindrome.check('raxdar')); | |
print(Palindrome.check('noon')); | |
print(Palindrome.check('nxoon')); | |
print(Palindrome.check('Rise to vote, sir!')); | |
print(Palindrome.check('Rise to xyz vote, sir!')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment