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.
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.
defminion_game(string):# your code goes herevowels='AEIOU'kevin=sum([len(string)-iforiinrange(len(string))ifstring[i]invowels])stuart=sum([len(string)-iforiinrange(len(string))ifstring[i]notinvowels])print('Draw'ifkevin==stuartelsef'Kevin{kevin}'ifkevin>stuartelsef'Stuart{stuart}')
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Minion Game
You are viewing a single comment's thread. Return to all comments →
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.