Skip to content

Instantly share code, notes, and snippets.

@amonks
Created April 9, 2015 00:04
Show Gist options
  • Save amonks/b67f333408c0b3b586ff to your computer and use it in GitHub Desktop.
Save amonks/b67f333408c0b3b586ff to your computer and use it in GitHub Desktop.
"hello".rot(13)
class String
def rot num = 13
self.upcase.split("").collect { |char|
((char.ord - 'A'.ord + num) % 26 + 'A'.ord).chr()
}.join()
end
def tryRot
(0..26).each do |i|
p "#{i}: '#{self.rot(i)}'"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment