Created
April 11, 2019 16:42
-
-
Save elcortez/5d4cf7932422203150146564b2e848ab to your computer and use it in GitHub Desktop.
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
| def encrypt(text) | |
| alphabet = ("A".."Z").to_a | |
| text.split(' ').map do |word| | |
| word.split('').map do |letter| | |
| position = alphabet.index(letter) | |
| new_position = position - 3 | |
| alphabet[new_position] | |
| end.join('') | |
| end.join(' ') | |
| end | |
| p encrypt("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG") | |
| p encrypt("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG") == "QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment