The Minion Game

  • + 1 comment

    This is pretty straightforward because we just need to return the total scores (counts), and not the actual breakup of scores per substring. I am trying to shorten my code. But as of now, this is it.

    def minion_game(string:str):
        VOWELS = ['A','E','I','O','U']
        n=len(string)
        k_score, s_score = 0,0
        
        for i in range(n):
            if string[i] in VOWELS:
                k_score += (n-i)
            else:
                s_score += (n-i)
    
        if k_score > s_score:
            print(f"Kevin {k_score}")
        elif k_score < s_score:
            print(f"Stuart {s_score}")
        else:
            print("Draw")