S1 = "abcdefghijklmnopqrstuvwxyz" S2 = "cqlmdrstfxyzbanopuvweghijk" s = gets.chomp puts s.gsub(/[a-z]/){|c| S2[S1.index(c)]}