Created
October 19, 2017 18:12
-
-
Save dip00dip/4507625f0af139338f06b9d64845939c to your computer and use it in GitHub Desktop.
sample use of ruby array .zip method for implementing Caesar cypher
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
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