##18.rb a = ('A'..'Z').to_a ll = gets.chomp.split("").map(&:to_s) r = [] Array(ll).each_with_index do |l,i| if a.index(l) - i - 1 >= 0 r.push(a[a.index(l) - i - 1]) else r.push(a[a.index(l) - i + a.length - 1]) end end print r.join