Created
October 10, 2019 16:42
-
-
Save barangerbenjamin/af12136b37270640a3f545a847bbd3eb 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 acronymize(string) | |
string.split(" ").map { |word| word[0].upcase }.join | |
end |
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 encrypt(text) | |
alphabet = ('A'..'Z').to_a | |
new_string = "" | |
text.chars.each do |letter| | |
if alphabet.include?(letter) | |
letter_index = alphabet.index(letter) | |
new_string += alphabet[letter_index - 3] | |
else | |
new_string += letter | |
end | |
end | |
new_string | |
end | |
puts 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