Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,3 @@
|
|||
func isPalindromeReverse(string: String): Boolean {
|
||||
return string == string.reverse();
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
func isPalindromeChars(chars: List<String>): Boolean {
|
||||
match (chars) {
|
||||
[]: return true;
|
||||
[elem]: return true;
|
||||
[first, middle*, last]: return first == last && isPalindromeChars(middle);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
func isPalindrome(string: String): Boolean {
|
||||
return isPalindromeReverse(string) && isPalindromeChars(string.chars);
|
||||
}
|
||||
|
||||
assert isPalindrome("");
|
||||
assert isPalindrome("f");
|
||||
assert isPalindrome("noon");
|
||||
assert isPalindrome("kayak");
|
||||
assert isPalindrome("step on no pets");
|
||||
assert !isPalindrome("palindrome");
|
||||
assert !isPalindrome("A man, a plan, a canal - Panama!"); //inexact
|
||||
|
||||
assert isPalindrome("§★♖★§"); //single utf16 code points
|
||||
assert isPalindromeReverse("🗲"); //string reverse handles surrogates
|
||||
assert !isPalindromeChars("🗲".chars); //.chars splits surrogates into two chars
|
||||
Loading…
Add table
Add a link
Reference in a new issue