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

What is a Decorator in Python?

Advantages of Using Docker for Microservices

Azure Databricks for Data Noobs Part 1 — The Basics

HPACK: Huffman encoder

The Ultimate Single-Page App for Developers and IT Pros: Your Terminal.

How to Become Disruptive: The Promising History of Low-Code

Level Up Your SQL Skills

The Hidden Risks of Using Excel To Manage Your Projects or Data

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

Replicated Acoustic Features Parkinson Database

Learning How to Use Python

LightGBM Starter Code

Lambda Functions in Python -II