# The Minion Game Hackerrank Solution In Python

Published November 3, 2023 by Jarvis Silva

In this article, I will share the The Minion Game Hackerrank Solution In Python. Hackerrank is a popular online platform which has many programming challenges and competitions which allows developers to participate into them and improve their programming skill.

## Question

In The Minion Game,” players Stuart and Kevin are given a string of uppercase letters. Stuart’s goal is to create words starting with consonants, while Kevin’s goal is to create words starting with vowels. Players score points based on the number of times their words appear in the given string. Write a Python function that determines the winner (Stuart or Kevin) and their score. If it’s a tie, print “Draw.” The input is a single string of uppercase letters.

You can find the full question of this problem here: Minion Game Hackerrank Challenge Question.

Before moving to the solution you should definately try to do this on your own it is very easy but still if you can’t solve it don’t worry you can check the below solution and understand this program.

## The Minion Game Hackerrank Solution Code In Python

``````
def minion_game(string):
vowels = "AEIOU"
stuart_score = 0
kevin_score = 0

# Calculate scores for Stuart and Kevin
for i in range(len(string)):
if string[i] in vowels:
kevin_score += len(string) - i
else:
stuart_score += len(string) - i

# Determine the winner and print the result
if kevin_score > stuart_score:
print("Kevin", kevin_score)
elif kevin_score < stuart_score:
print("Stuart", stuart_score)
else:
print("Draw")
```
```

Above is the python code for the minion game hackerrank challenge, you can submit the above code in hackerrank and it should show you congratulations you solved this challenge.

So this was for this article, I hope you found what you were looking and if you want more hackerrank solutions then visit here: Hackerrank python solutions.

Thank you for reading, Happy coding 😊

View All