Created
April 9, 2015 00:04
-
-
Save amonks/b67f333408c0b3b586ff to your computer and use it in GitHub Desktop.
"hello".rot(13)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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