The Minion Game

Sort by

recency

|

1275 Discussions

|

  • + 0 comments
    def minion_game(string):
        import re
        strLen = len(string)
        regexVovels = re.compile(r'[aeiouAEIOU]')
        vovelIndexex = [match.start() for match in regexVovels.finditer(string)]
        scoreVovels = sum(map(lambda x: len(string)-x , vovelIndexex))
        totalScore = strLen*(strLen+1)/2
        scoreConsonents = int(totalScore - scoreVovels)
        
        if scoreVovels == scoreConsonents:
            print(f'Draw')
        elif scoreConsonents > scoreVovels:
            print(f'Stuart {scoreConsonents}')
        else:
            print(f'Kevin {scoreVovels}')
    
  • + 0 comments

    So. I was wondering why I still dont get correct answers for some tests, though I saw no error in my code. Ok, I have then, in despair, looked in the Editorial and voilà: Y is considered a consonant in English! Well, it's actually a bit complicated with this letter in English, as I have learned recently, but in many other languages, "Y" is a pretty normal vowel - maybe if it was stressed in the instructions, which letters are considered vowels, it would be no harm to anyone and help for many.

  • + 0 comments

    Tough! started by working out all possible words, then looping through several time before it clicked!

    string_length = len(string)
    total_words = total = sum(range(string_length + 1))
    kevin_score = sum([string_length - x[0] for x in enumerate(string) if x[1] in 'AEIOU'])
    stuart_score = total_words - kevin_score
    print("Draw" if kevin_score == stuart_score else f"Kevin {kevin_score}" if kevin_score > stuart_score else f"Stuart {stuart_score}" )
    
  • + 0 comments
    def minion_game(string):
        vowels = "AEIOU"
        Kevin_score = 0
        Stuart_score = 0
        
        for i in range(len(string)):
            if string[i] in vowels:
                Kevin_score += len(string) - i
            else:
                Stuart_score += len(string) - i
        
        if Stuart_score > Kevin_score:
            print("Stuart", Stuart_score)
        elif Stuart_score == Kevin_score:
            print("Draw")
        else:
            print("Kevin", Kevin_score)
    
  • + 0 comments
    from collections import Counter
    
    vowels = "AEIOU"
    
    def minion_game(txt):
        # your code goes here
        length = len(txt)
        score = Counter()
        for i, ch in enumerate(txt):
            points = length - i
            score[ch in vowels] += points  
        # print(score)
        
        if (kevin := score[True]) > (stuart := score[False]):
            print(f"Kevin {kevin}")
        elif stuart > kevin:
            print(f"Stuart {stuart}")
        else:
            print("Draw")
                
    # Input (stdin)
    # BANANA
    # Expected Output
    # Stuart 12