Skip to content

Instantly share code, notes, and snippets.

@dip00dip
Created October 19, 2017 18:12
Show Gist options
  • Save dip00dip/4507625f0af139338f06b9d64845939c to your computer and use it in GitHub Desktop.
Save dip00dip/4507625f0af139338f06b9d64845939c to your computer and use it in GitHub Desktop.
sample use of ruby array .zip method for implementing Caesar cypher
letters = Array('a'..'z')
shift = 3
translation_map = letters.zip(letters.rotate(shift)).to_h
"hello".chars.map { |ch| translation_map[ch] }.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment