您的位置:首页 > 编程语言 > Python开发

Python HackerRank|The Minion Game

2017-02-23 22:27 507 查看
Dashboard 

 Python 

 Strings 

 The
Minion Game

def minion_game(string):
vowels = 'AEIOU'
Stuart = 0
Kevin = 0
length = len(string)
for i in range(length):
if string[i] in vowels:
Kevin += (length - i)
else:
Stuart += (length - i)
# For example, BANANA, 'B'(s[0]) not in vowels, so B, BA, BAN, BANA, BANAN, BANANA, altogether 6(length - 0), are all we need.
if Stuart > Kevin:
print('Stuart', Stuart)
elif Stuart < Kevin:
print('Kevin', Kevin)
else:
print('Draw')

if __name__ == '__main__':
s = input()
minion_game(s)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: