In this Python program, a game called 'The Minion Game' is implemented. The game is played between two players, Stuart and Kevin. They are given a string, and they score points based on the occurrence of vowels and consonants in the string. Stuart scores points for consonants, while Kevin scores points for vowels. The player with the highest score at the end of the game wins.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The solution works by iterating over the input string and checking each character. If the character is a vowel, Kevin's score is increased by the length of the string minus the current index. If the character is a consonant, Stuart's score is increased by the same amount. This is because each substring starting with a particular character contributes to the player's score. After checking all characters, the scores of Stuart and Kevin are compared to determine the winner. If the scores are equal, the game is a draw.
s = input().strip()
s_length = len(s)
vowel_list = ["A", "E", "I", "O", "U"]
stuart_point = 0
kevin_point = 0
for i in range(s_length):
if s[i] in vowel_list:
kevin_point += s_length - i
else:
stuart_point += s_length - i
if stuart_point == kevin_point:
print("Draw")
elif kevin_point > stuart_point:
print("Kevin", kevin_point)
else:
print("Stuart", stuart_point)
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.