Join Hacktoberfest 2023: Contribute to open source, learn, and earn rewards. Beginner-friendly. Explore issues, fork, code, and make a global impact. Let's collaborate!
Define the minion_game function, which takes a string as input.
Initialize kevin_score and stuart_score to keep track of the scores for Kevin and Stuart, respectively.
Calculate the length of the input string length.
Loop through the characters in the string and determine whether they are vowels (Kevin) or consonants (Stuart). For each character, calculate the number of substrings that start with that character and add that count to the respective player's score.
After calculating the scores, compare them to decide the winner. Print the winner's name and score or "Draw" if the scores are equal.
In the main part of the code, read the input string from the user and call the minion_game function to determine the winner and display the result.
Here's how the code works:
Define the
minion_game
function, which takes a string as input.Initialize
kevin_score
andstuart_score
to keep track of the scores for Kevin and Stuart, respectively.Calculate the length of the input string
length
.Loop through the characters in the string and determine whether they are vowels (Kevin) or consonants (Stuart). For each character, calculate the number of substrings that start with that character and add that count to the respective player's score.
After calculating the scores, compare them to decide the winner. Print the winner's name and score or "Draw" if the scores are equal.
In the
main
part of the code, read the input string from the user and call theminion_game
function to determine the winner and display the result.