Python HackerRank|The Minion Game

来源:互联网 发布:软件需求 功能需求 编辑:程序博客网 时间:2024/06/09 20:27
  1. Dashboard 
  2.  Python 
  3.  Strings 
  4.  The Minion Game
    1. def minion_game(string):    vowels = 'AEIOU'    Stuart = 0    Kevin = 0    length = len(string)    for i in range(length):        if string[i] in vowels:            Kevin += (length - i)        else:            Stuart += (length - i)            # For example, BANANA, 'B'(s[0]) not in vowels, so B, BA, BAN, BANA, BANAN, BANANA, altogether 6(length - 0), are all we need.    if Stuart > Kevin:        print('Stuart', Stuart)    elif Stuart < Kevin:        print('Kevin', Kevin)    else:        print('Draw')        if __name__ == '__main__':    s = input()    minion_game(s)


0 0