The Minion Game

  • + 1 comment

    The number of subsets of a substring is same as length of string minus its index.

    def minion_game(string):
        stuart_score, kevin_score = 0, 0
        
        for i in range(len(string)):
            if string[i] in "AEIOU":
                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("Kevin", kevin_score)
        else:
            print("Draw")
    
    if __name__ == '__main__':
        s = input()
        minion_game(s)