Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2012 20:09
Show Gist options
  • Save anonymous/1556669 to your computer and use it in GitHub Desktop.
Save anonymous/1556669 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
ab = (?A..?Z).to_a
n = $<.readline.to_i
str = $<.read
puts str.split('').map {|oc| c = oc.upcase; if ab.include? c then r = ab[(ab.index(c) - n) % ab.length]; c == oc ? r : r.downcase else c end }.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment