Editorial for Meow Meow


Author:kahootist

Code 1
# So we abuse this little thing called regular expressions ("re")
# which is a powerful tool for linear pattern matching in strings!
import re

# We define the regular expressions for the three sounds...
# + means one or more of the previous character
# ^ means the start of the line
# $ means the end of the line
hiss = re.compile("^hiss+$")
trill = re.compile("^tri+ll+$")
burble = re.compile("^bu+r+bl+e$")

# We read the number of test cases
count = int(input())

# For each test case, we read the sound and check which regular expression it matches,
# and print out the corresponding output!
for _ in range(count):
    noise = input()
    if hiss.match(noise) is not None:
        print("hiss")
    elif trill.match(noise) is not None:
        print("trill")
    elif burble.match(noise) is not None:
        print("burble")
    else:
        print("human noises")

# If you don't know how regular expressions work, don't worry!
# A plain if-else solution that manually goes through each string is just as valid!

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.