in reply to Finding longest palindrome from a string
Because the golf isn't complete without an insanely short regex solution:
Update: inspired by ccn's array approach:sub japhy { # 74 our$P="";pop=~m{(.+).?(??{reverse$1}) (?{length$P<length$&and$P=$&})^}xs;$P }
sub japhy { # 68 our@P="";pop=~m{(.+).?(??{reverse$ 1})(?{$P[length$&]=$&})^}xs;$P[-1] }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Finding longest palindrome from a string
by Jasper (Chaplain) on Aug 17, 2004 at 08:45 UTC |
In Section
Seekers of Perl Wisdom