The Minion Game

Sort by

recency

|

1259 Discussions

|

  • + 0 comments

    Something a little bit different, the total possible score can be caluclated using the arithmetic series formula (total = (n * (n+1) ) // 2). This allows Stuart's score to be caluclated as every point that Kevin didn't get.

    Code:

    def minion_game(string):
        VOWELS = ['A','E','I','O','U']
        n = len(string)
        total = (n * (n+1) ) // 2
        
        kevin = 0
        for i, char in enumerate(string):
            if char in VOWELS:
                kevin += n - i
        stuart = total - kevin
        
        if stuart > kevin:
            print(f"Stuart {stuart}")
        elif stuart == kevin:
            print("Draw")
        elif stuart < kevin:
            print(f"Kevin {kevin}")
    
  • + 0 comments
    def minion_game(string):
        # your code goes here
        vowel = ['A', 'E', 'I', 'O', 'U']
        
        vowel_pt = 0
        consonant_pt = 0
      
        
     
        for i in range(len(string)):
            if string[i] in vowel:
              vowel_pt += (len(string) - i)
            
            else:
                consonant_pt +=(len(string) - i)
                    
        if vowel_pt > consonant_pt:
            print("Kevin", vowel_pt)
        
        elif consonant_pt > vowel_pt:
            print("Stuart", consonant_pt)
        else:
            print("Draw")
                
        # print(score["Stuart"])
            
    
    if __name__ == '__main__':
        s = input()
        minion_game(s)
    
  • + 0 comments

    The rules give each player a distinct focus—consonants for Stuart and vowels for Kevin—adding a strategic layer that makes things more interesting. Betbook250 login

  • + 0 comments

    This problem is kind a triky process AND YOU NEED TO REFRES THE CONCEPT OF COMBINATION the solution is in the for loop:

    for i in range(length):
        if string[i] in vowels:
            kevin += length - i
        else:
            stuart += length - i
    

    and understand this : posible combination of substrIng in a string that is the cycle do, so : 'B,A,N,A,N,A' 0 (get 6 substring): * 'B' , 'BA' , 'BAN' , 'BANA' , 'BANAN' , 'BANANA'* 1 (get 5 substring):** 'A' , 'AN' , 'ANA' , 'ANAN' , 'ANANA** 2 (get 4 substring): * 'N' , 'NA' , 'NAN' , 'NANA'* 3 (get 3 substring):** 'A' , 'AN' , 'ANA'** 4 (get 2 substring): * 'N' , 'NA' * 5 (get 1 substring): ** 'A'**

    NOW AS you can see they start in vowey or not vowel so if you sum you get result ,

  • + 0 comments

    Here's my code:

    def minion_game(s):
        vowels, n, scores = 'AEIOU', len(s), {'Kevin': 0, 'Stuart': 0}
        for i, char in enumerate(s):
            scores['Kevin' if char in vowels else 'Stuart'] += n - i
        winner = max(scores, key=scores.get)
        print(f'{winner} {scores[winner]}' if len(set(scores.values())) > 1 else 'Draw')