The Minion Game : HackerRank Solution in Python

Solution in Python 3

def minion_game(string):
s=len(string)
vowel = 0
consonant = 0

for i in range(s):
if string[i] in 'AEIOU':
vowel+=(s-i)
else:
consonant+=(s-i)

if vowel < consonant:
print('Stuart ' + str(consonant))
elif vowel > consonant:
print('Kevin ' + str(vowel))
else:
print('Draw')

Explanation

for i in range(s):
if string[i] in 'AEIOU':
vowel+=(s-i)
else:
consonant+=(s-i)
if vowel < consonant:
print('Stuart ' + str(consonant))
elif vowel > consonant:
print('Kevin ' + str(vowel))
else:
print('Draw')

--

--

--

pretending to teach is one of the best way to learn.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

“ATT&CK with Sub-Techniques” is Now Just ATT&CK

A320 Immersion V2 has arrived for the Aerosoft A320 Professional!

How-to Install JupyterHub Using Conda Without Running as Root and Make It a Service

SEO Benefits of HTML5 and Schema

Spring Aspect oriented programming — AOP — Part 1

On learning and teaching in programming and technology

How performance budgets and SpeedCurve are helping us keeping a high performant website

Agile — Is it a silver bullet?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shounak Lohokare

Shounak Lohokare

pretending to teach is one of the best way to learn.

More from Medium

CRUNCH COUNTER IN PYTHON

Constructor Type in Python

Python, the developer-oriented programming language

Common Operations with Numbers, Strings and Lists in Python