22 lines
1,021 B
Text
22 lines
1,021 B
Text
print isPalindrome("In girum imus nocte et consumimur igni")
|
|
print isPalindrome(removePunctuation$("In girum imus nocte et consumimur igni", "S"))
|
|
print isPalindrome(removePunctuation$("In girum imus nocte et consumimur igni", "SC"))
|
|
|
|
function isPalindrome(string$)
|
|
isPalindrome = 1
|
|
for i = 1 to int(len(string$)/2)
|
|
if mid$(string$, i, 1) <> mid$(string$, len(string$)-i+1, 1) then isPalindrome = 0 : exit function
|
|
next i
|
|
end function
|
|
|
|
function removePunctuation$(string$, remove$)
|
|
'P = remove puctuation. S = remove spaces C = remove case
|
|
If instr(upper$(remove$), "C") then string$ = lower$(string$)
|
|
If instr(upper$(remove$), "P") then removeCharacters$ = ",.!'()-&*?<>:;~[]{}"
|
|
If instr(upper$(remove$), "S") then removeCharacters$ = removeCharacters$;" "
|
|
|
|
for i = 1 to len(string$)
|
|
if instr(removeCharacters$, mid$(string$, i, 1)) then string$ = left$(string$, i-1);right$(string$, len(string$)-i) : i = i - 1
|
|
next i
|
|
removePunctuation$ = string$
|
|
end function
|