Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
isPalindrome = function(s)
|
||||
// convert to lowercase, and strip non-letters
|
||||
stripped = ""
|
||||
for c in s.lower
|
||||
if c >= "a" and c <= "z" then stripped = stripped + c
|
||||
end for
|
||||
|
||||
// check palindromity
|
||||
mid = floor(stripped.len/2)
|
||||
for i in range(0, mid)
|
||||
if stripped[i] != stripped[-i - 1] then return false
|
||||
end for
|
||||
return true
|
||||
end function
|
||||
|
||||
testStr = "Madam, I'm Adam"
|
||||
answer = [testStr, "is"]
|
||||
if not isPalindrome(testStr) then answer.push "NOT"
|
||||
answer.push "a palindrome"
|
||||
print answer.join
|
||||
Loading…
Add table
Add a link
Reference in a new issue