Longest palindromic substrings: Difference between revisions
→faster: bugfix
(→faster: bugfix) |
|||
Line 385:
sequence res = {}
for i=1 to length(s) do
integer
while rev<i and i+fwd<=length(s) and s[i-rev]=s[i+fwd]
if lp>=longest then
res = append(res,p)
end if
end if
end
end for
return res -- (or "sort(res)" or "unique(res)", as needed)
end function
printf(1,"%s: %v\n",{s,longest_palindromes_raku(piStr)})
s = "abbbc"
printf(1,"%s: %v\n",{s,longest_palindromes_raku(s)})</lang>
{{out}}
(first line matches the above, the second was a initially a bug)
<pre>
3.141592653589793238...05600101655256375679 (10,002 digits): {"398989893","020141020"}
abbbc: {"bbb"}
</pre>
=={{header|Python}}==
|