input = gets output = "" alphabet = ('A'.ord..'Z'.ord).to_a.map(&:to_i).map(&:chr) gap = 1 input.split(//).each_with_index{|val, index| if index < input.length - 1 then output << alphabet[(val.ord - 65 - gap) % 26].to_s end gap+=1 } puts output