The Minion Game

  • + 0 comments
    def minion_game(string):
        n = len(string)
        S = string.upper()          # be robust to case
        vowels = set("AEIOU")
    
        kevin = 0   # vowel player
        stuart = 0  # consonant player
    
        for i, ch in enumerate(S):
            if ch in vowels:
                kevin += n - i
            else:
                stuart += n - i
    
        if kevin > stuart:
            print(f"Kevin {kevin}")
        elif stuart > kevin:
            print(f"Stuart {stuart}")
        else:
            print("Draw")