-
-
Save johnzeringue/fe1f96c86c86e31ec388 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
#!/usr/bin/env ruby | |
VOWELS = "AEIOUYÅÄÖ" | |
CONSONANTS = ('A'..'Z').reject { |char| VOWELS.include? char } | |
def consonant? char | |
CONSONANTS.include? char or CONSONANTS.include? char.upcase | |
end | |
def rovarspraket string | |
string.each_char.map do |char| | |
if consonant? char | |
char + 'o' + char.downcase | |
else | |
char | |
end | |
end.join | |
end | |
INPUT_1 = "Jag talar Rövarspråket!" | |
OUTPUT_1 = "Jojagog totalolaror Rorövovarorsospoproråkoketot!" | |
INPUT_2 = "I'm speaking Robber's language!" | |
OUTPUT_2 = "I'mom sospopeakokinongog Rorobobboberor'sos lolanongoguagoge!" | |
throw "Input 1 failed." unless rovarspraket(INPUT_1) == OUTPUT_1 | |
throw "Input 2 failed." unless rovarspraket(INPUT_2) == OUTPUT_2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment