The Minion Game with Python

eren.eth
2 min readFeb 21, 2022

Hello Medium, after a long break I decided to come back to publishing stories here, but now I’m writing in English to make it global. I wanted to share the solution of The Minion Game, which I solved today.

First, let’s talk about the Python Problem itself, What is The Minion Game?

(Let’s Say) Kevin and Stuart want to play the ‘The Minion Game’.

Game Rules

Both players are given the same string, S
Both players have to make substrings using the letters of the string S.
Stuart has to make words starting with consonants.
Kevin has to make words starting with vowels.

The game ends when both players have made all possible substrings.

Scoring

A player gets +1 point for each occurrence of the substring in the string S.

For Example :
String S = BANANA
Kevin’s vowel beginning word = ANA
Here, ANA occurs twice in BANANA. Hence, Kevin will get 2 Points.

For better understanding, see the image below:

All we have to do is determine the winner and print the score.

Input Format :

A single line of input containing the string S.

Note: The string S will contain only uppercase letters:[A — Z] .

Constraints :

  • 0 < len(s) <= 10⁶

Output Format :

Print one line: the name of the winner and their score separated by a space.

If the game is a draw, print Draw.

Here’s my solution :

First, I wrote two variables, kevin and stuart, to indicate the scores.

Next, I wrote a variable specifying the length of the String input. (str_len)

Then I wrote an if statement (for make Kevin start with vowels and Stuart start with consonants) inside a for loop, depending on whether it contains a vowel or not.

then I simply wrote an if statement showing (printing) whether Kevin or Stuart had a bigger score (or equal).

That’s it! See you in my next story :)

--

--