Editorial for Meow Meow
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
# 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!
Comments