$chars = ('a'..'z').to_a

def crypt_caesar(s, n)
  s.chars.to_a.map{|c|
    if 'a'.ord <= c.ord && c.ord <= 'z'.ord
      $chars[((c.ord - 'a'.ord) + n) % $chars.size]
    else
      c
    end
  }.join
end

$<.each_line do |rawText|
  0.upto($chars.size) do |n|
    text = crypt_caesar(rawText, n)
    if text =~ /the|this|that/
      puts text
    end
  end
end