Created
July 5, 2016 14:54
-
-
Save flanger001/fb72bc9391d3b04b49c4f0a40d375a96 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 caesar(key, text) | |
az = ('A'..'Z').to_a | |
rt = az.rotate(key) | |
chars = text.split('') | |
.select { |c| az.include?(c) } | |
.map { |c| rt[az.index(c)] } | |
.join('') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment