Python HackerRank|The Minion Game
2017-02-23 22:27
507 查看
Dashboard
Python
Strings
The
Minion Game
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)
相关文章推荐
- Python HackerRank|The Captain's Room
- [HackerRank 101 Hack 51] Testing the Game
- 【Hackerrank】Find the merge point of two joined linked lists
- 莱斯大学Python课程Mini-project# 3 - "Stopwatch: The Game"
- HackerRank - The Maximum Subarray
- HackerRank# The Longest Common Subsequence
- HackerRank# Bricks Game
- Interactive Python:Mini-project # 1 - "Guess the number" game"
- HackerRank - "Snakes and Ladders: The Quickest Way Up"
- HackerRank - Sherlock and The Beast
- HackerRank - Game of Thrones - I
- [HackerRank] The Longest Common Subsequence
- Hackerrank - Coin on the Table 题解
- 【HackerRank】Find the Median(Partition找到数组中位数)
- 【HackerRank】Game Of Rotation
- HackerRank(FP) - The Sums of Powers
- 莱斯大学Python课程Mini-project # 2 - "Guess the number" game
- 【HackerRank】 The Full Counting Sort
- *[hackerrank]Cut the tree
- HackerRank - The Trigonometric Ratios (Code Golf)