Created
September 9, 2017 08:35
-
-
Save kp666/36b78de9f27c4adc795838f71f84fee3 to your computer and use it in GitHub Desktop.
This file contains 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
def all_alphabets | |
[[*'A'..'Z'], [*'a'..'z']] | |
end | |
def rotated_by_key(key) | |
all_alphabets.flat_map{|x|x.rotate(key)} | |
end | |
def ceaser(string,key) | |
string.tr(all_alphabets.join,rotated_by_key(key).join) | |
end | |
ceaser("This is my string",13) | |
ceaser("SDS Coding Challenge #3",20 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment