Re:Can you solve it? The Greplin programming challenge
by leif on Friday October 08, 2010 @11:44PM
(#1774290)
I can't read ruby, but here's something a little smarter than brute force in C (on its way to DP, but I couldn't be arsed to work out the recurrence so I just iterated until it stabilized): http://gist.github.com/617854
Re:Can you solve it? The Greplin programming challenge
by dasil003 on Saturday October 09, 2010 @12:58AM
(#1774370)
It looks similar to mine, but you got lucky (or unlucky depending on how you look at it) that the longest palindrome had an odd character count.
The confusing bits in the Ruby are actually just the definition of an even and odd palindrome finder, which are the same except for two seed values for where the first comparison is conducted and it's length.
Is there a better algorithm? Dynamic programming of some sort? I guess we'd need a longer string to tell the difference.