File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ #Kevin and Stuart want to play the 'The Minion Game'.
2
+
3
+ #Game Rules
4
+
5
+ #Both players are given the same string S .
6
+ #Both players have to make substrings using the letters of the string S.
7
+ #Stuart has to make words starting with consonants.
8
+ #Kevin has to make words starting with vowels.
9
+ #The game ends when both players have made all possible substrings.
10
+
11
+ #Scoring
12
+ #A player gets +1 point for each occurrence of the substring in the string S.
13
+
14
+ #Function to find the winner
15
+ def the_minion_game (s ):
16
+
17
+ vowels = 'AEIOU'
18
+ kevin = 0
19
+ stuart = 0
20
+ for i in range (len (s )):
21
+ if s [i ] in vowels :
22
+ kevin += (len (s )- i )
23
+ else :
24
+ stuart += (len (s )- i )
25
+
26
+ if kevin > stuart :
27
+ print ("Kevin won the game with score:" , kevin )
28
+ elif kevin < stuart :
29
+ print ("Stuart won the game with score:" , stuart )
30
+ else :
31
+ print ("Draw" )
32
+
33
+
34
+ s = input ("Enter the String: " )
35
+ the_minion_game (s )
You can’t perform that action at this time.
0 commit comments