Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created September 12, 2015 19:22
Show Gist options
  • Save emad-elsaid/04647c9b80e65e3bbe86 to your computer and use it in GitHub Desktop.
Save emad-elsaid/04647c9b80e65e3bbe86 to your computer and use it in GitHub Desktop.
chars = ('a'..'z').to_a*2 + ('A'..'Z').to_a*2
n = gets
s = gets.strip
k = gets.to_i%26
s.each_char.with_index do |char, index|
s[index] = (chars.index(char).nil? ? char : chars[chars.index(char)+k])
end
puts s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment