We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- The Minion Game
- Discussions
The Minion Game
The Minion Game
Sort by
recency
|
1313 Discussions
|
Please Login in order to post a comment
I'd call this a cleanup of jpconcerman's solution using list comprehension and a ternary operator for the result. A plain old string will suffice for the vowel list as well but I'm not sure if a list or set ends up being computationally cheaper. For 5 characters though I'd assume the difference is negligible and all three will pass all test cases without timing out.
Can I understand more why it is sufficient to check the occurences of each character to keep the score, and we do not need the generate the words to check for occurrences?
def minion_game(string): vowels = ('A', 'E', 'I', 'O', 'U') kevin_score = 0 stuart_score = 0 len_str = len(string)
if name == 'main': s = input() minion_game(s)
def minion_game(string): n = len(string) S = string.upper() # be robust to case vowels = set("AEIOU")