Skip to content

Instantly share code, notes, and snippets.

@rjlutz
Created June 10, 2018 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjlutz/68fdfee69bc9bfafd7fb4120713d6ee4 to your computer and use it in GitHub Desktop.
Save rjlutz/68fdfee69bc9bfafd7fb4120713d6ee4 to your computer and use it in GitHub Desktop.
template for porting Palindrome.java to dart
// 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