Skip to content

Instantly share code, notes, and snippets.

@flanger001
Created July 5, 2016 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flanger001/fb72bc9391d3b04b49c4f0a40d375a96 to your computer and use it in GitHub Desktop.
Save flanger001/fb72bc9391d3b04b49c4f0a40d375a96 to your computer and use it in GitHub Desktop.
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