class A def initialize s = gets.chomp.chars answer = [] list = [*('A'..'Z')] s.each.with_index(1) do |ch, index| answer << list[(ch.ord - 'A'.ord - index)%26] end puts answer.join end end A.new