Hacker News new | ask | show | jobs
by erwanb 5596 days ago
here is a naive but working way to do it in ruby : https://gist.github.com/849625
2 comments

Python:

max((s[start:end] for start in xrange(len(s)) for end in xrange(start, len(s)) if s[start:end]==s[start:end][::-1]), key=len)

Thank you. 0.upto(string.length - password_length) do |index| that's the line of logic I didn't it get correct.