##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 rp = i / a.length r.push(a[a.index(l) - i + rp * a.length - 1]) end end print r.join.to_s