Created
February 14, 2022 20:38
-
-
Save UltiRequiem/925a569a70a3e83a1a73c41b59a3e3a3 to your computer and use it in GitHub Desktop.
centaui_prime
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
VALID_VOWELS = ["A", "E", "I", "O", "U", "a", "e", "i", "o", "u"] | |
consonants = "bcdfghjklmnpqrstvwxz" + "BCDFGHJKLMNPQRSTVWXZ" | |
def is_vowel(string): | |
return string in VALID_VOWELS | |
RULERS = {"vowels": "Alice", "consonants": "Bob", "y": "nobody"} | |
def get_ruler(kingdom: str): | |
last_letter = kingdom[-1] | |
if is_vowel(last_letter): | |
return RULERS["vowels"] | |
elif last_letter in consonants: | |
return RULERS["consonants"] | |
else: | |
return RULERS["y"] | |
def main(): | |
T = int(input()) | |
for t in range(T): | |
kingdom = input() | |
print("Case #%d: %s is ruled by %s." % (t + 1, kingdom, get_ruler(kingdom))) | |
if __name__ == "__main__": | |
main() |
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 ruler(kingdom: str): | |
last_letter = kingdom[-1].lower() | |
if "y" == last_letter: | |
return "nobody" | |
if last_letter in "aeiou": | |
return "Alice" | |
return "Bob" | |
def main(): | |
cases = int(input()) | |
for case in range(1, cases + 1): | |
kingdom = input() | |
print(f"Case #{case}: {kingdom} is ruled by {ruler(kingdom)}.") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment