VOVELS set AEIOU def minion_game inp inp bytearray inp latin kev st le

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
VOVELS = set(b'AEIOU')
def minion_game(inp):
inp = bytearray(inp, 'latin')
kev = 0
st = 0
len_inp = len(inp)
kev_odds = [0 for x in range(len_inp)]
for idx, char in enumerate(inp):
prev = 0 if idx == 0 else kev_odds[idx - 1]
kev_odds[idx] = prev + (1 if char in VOVELS else 0)
for sub_len in range(1, len_inp + 1):
z = kev_odds[len_inp - sub_len]
kev += z
st += (sub_len - z)
if st > kev:
print('Stuart', st)
elif st < kev:
print('Kevin', kev)
else:
print('Draw')
if __name__ == '__main__':
#s = input()
with open('var/game_input') as inp:
s = inp.read()
import time
start = time.time()
minion_game(s)
stop = time.time()
print('%.04f' % (stop - start))