Created
December 10, 2020 17:55
-
-
Save willshepp28/7dda16d1adca2091362e88606f16b3d5 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
# @param {String} command | |
# @return {String} | |
def interpret(command) | |
output = "" | |
command.split('').each_with_index { |character, idx| | |
if character == "G" | |
output += "G" | |
elsif character == "(" | |
if command[idx + 1] == ")" | |
output += "o" | |
elsif command[idx + 1] == "a" && command[idx + 2] = "l" && command[idx + 3] = ")" | |
output += "al" | |
end | |
end | |
} | |
return output | |
end | |
interpret("G()()()()(al)G") | |
interpret("(al)G(al)()()G") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment