Skip to content

Instantly share code, notes, and snippets.

@rjlutz rjlutz/main.dart
Created Jun 10, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.