Re:Can you solve it? The Greplin programming challenge
by staunch on Friday October 08, 2010 @08:19PM
(#1773955)
Easy job for a regex:
[ Parent
| on HN ]
Re:Can you solve it? The Greplin programming challenge
by dantle on Saturday October 09, 2010 @12:33AM
(#1774345)
fuckin nice. now I feel like a doofus for using ruby, when I thought it was straightforward.
Re:Can you solve it? The Greplin programming challenge
by manveru on Saturday October 09, 2010 @06:36AM
(#1774809)
I've done it ruby this way:
text.scan(/(.)(.)(.)(.)(\3)(\2)(\1)/)
Re:Can you solve it? The Greplin programming challenge
by Natsu on Monday October 11, 2010 @05:38AM
(#1779249)
That's pretty frail. It won't catch palindromes with an even number of letters (e.g. ababbaba) and it'll only find those of at most 7 characters. Granted, you can use those matches to work outwards and search for more, but I didn't think the general solution was all that hard.
Oddly enough, it didn't even occur to me to try a regex and I like using them quite a bit.