The Minion Game

Sort by

recency

|

1310 Discussions

|

  • + 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")
    
  • + 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")
    
  • + 0 comments

    who's code passed test case 4?

  • + 0 comments

    the code works well take in consideration test case where the word starts with char other tahn Alpha ex '1' or '_' the problem with test cases 4 is the memory allocation when I run the code on my pc it gives the right answer :

  • + 0 comments
    def minion_game(string: str) -> None:
        # Stuart -> Consonents, Kevin -> Vowels
    
        vowels = "AEIOU"
    
        length = len(string)
    
        stuart_score, kevin_score = 0, 0
    
        for i in range(length):
            if string[i] in vowels:
                kevin_score += length - i
            else:
                stuart_score += length - i
    
        if kevin_score > stuart_score:
            print("Kevin", kevin_score)
        elif stuart_score > kevin_score:
            print("Stuart", stuart_score)
        else:
            print("Draw")