Monday, July 12, 2010

On Palindromes

la porte du palindrome / the palindrome doorImage by TisseurDeToile -[*] via Flickr



Example from class:

var s = "Too Hot, to Hoot!!"
var arr = s.split(' ')
var result = ''


//process all words in sentence
for(var i = 0; i < arr.length; ++i)
//result = result + encode(arr[i]) + ' '
arr[i] = encode(arr[i])



Example from Class

var s = "Radar, mom!"
var arr = s.split(' ')
var i = 0


//check words
//not quite there yet..
while(isPalindrome(arr[i]) && i < arr.length){
++i
}

//determine result
if(i == arr.length)
//every word is a pal
else
//not all words are pals
Enhanced by Zemanta

No comments: