Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. def find_longest_palindrom s1, size
  2.     longest = ""
  3.  
  4.     s1.size.times do |start|
  5.         break if start + size > s1.size
  6.         s2 = s1[start, size].reverse
  7.         if s1.include? s2
  8.             puts s2
  9.             exit
  10.         end
  11.     end
  12.    
  13.     find_longest_matching s1, size - 1
  14. end
  15.  
  16. find_longest_palindrom text, text.length