Palindrome Algorithm
By Unknown |You ever get a question that just bugs you until you solve it every way you can think. Today I was asked to write in pseudo-code a short algorithm for determining if a string was a palindrome. I wrote ECMAScript like scrawl and short a couple of important things that I missed I basically made a working palindrome function. But then I got home and wanted t actually test my code so I did and these are what I came up with. If you know a better way of have a language implementation I would love to see it to have some fun:
// JavaScript function pal(w){ return w.split('').reverse().join('') == w; } #Python def pal(w): return w == w[:-1]
0 comments: