# -*- coding: utf-8 -*- W = 'w' readlines.each { |s| ans = Array.new(100){ [] } s.size.times { |i| if s[i] != W && s[i+1] == W j = i t = '' while j >= 0 && s[j] != W t = s[j] + t j = j-1 end j = i+1 while j < s.size && s[j] == W j += 1 end ans[j-i] << t end } ans.reverse.each { |a| if a.size > 0 puts a break end } }