Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

here is a naive but working way to do it in ruby : https://gist.github.com/849625


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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: