Skip to content

Instantly share code, notes, and snippets.

@mortonfox
Last active December 25, 2015 12:39
Show Gist options
  • Save mortonfox/6977652 to your computer and use it in GitHub Desktop.
Save mortonfox/6977652 to your computer and use it in GitHub Desktop.
rot-all script
def rotall s
1.upto(25) { |i|
puts "#{i}: #{s.upcase.chars.to_a.map { |c|
case c
when /^[A-Z]$/
((c.ord - 'A'.ord + i) % 26 + 'A'.ord).chr
else
c
end
}.join ''}"
}
end
text = []
while line = gets
text << line.strip
end
rotall text.join ' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment