Skip to content

Instantly share code, notes, and snippets.

@UltiRequiem
Created February 14, 2022 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UltiRequiem/925a569a70a3e83a1a73c41b59a3e3a3 to your computer and use it in GitHub Desktop.
Save UltiRequiem/925a569a70a3e83a1a73c41b59a3e3a3 to your computer and use it in GitHub Desktop.
centaui_prime
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()
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