
-----------------------------------
scorpion1087
Thu Oct 30, 2003 4:27 pm

palindrome
-----------------------------------
how do you check if a palindrome is true

eg
mom will have 1 check because the m's cancel and whatever is in the middle is left over.

my email is scorpion1087@hotmail.com

ps how do you create a palindrome

-----------------------------------
Blade
Thu Oct 30, 2003 5:16 pm


-----------------------------------
umm... you'd have to use a reversed for loop and use two variables.... thats the easiest way
ex:
var word1,word2:string(30):=""
word:="mom"
for decreasing i:1..length(word1)
  word2+=word1(i)
end for
if (word1 = word2) then
  %is a palindrome
end if

thats just one way, theres more but i think thats the easiest...

-----------------------------------
Andy
Thu Oct 30, 2003 5:31 pm


-----------------------------------
you could also do this

var word :string:="mom"
for i:1..length(word) div 2
    for decreasing j: length(word)..length(word) div 2
        if word(i) not= word(j)
            put "no"
            return
        end if
    end for
end for

better than blade's method cuz u dont need a new var :lol:

-----------------------------------
Blade
Sun Nov 02, 2003 1:41 am


-----------------------------------
thats just one way, theres more but i think thats the easiest...

duh - didnt say it was the best
