Completed A challenge on HackerRank: Develop a game where a given string is split into all possible substrings and then depending on the beginning of the substring (vowel or consonant) determines which player (Kevin or Stuart) received a point. Hoping I could get advice on neatness, anything I did wrong/needs to be done better.
''' https://www.hackerrank.com/challenges/the-minion-game/problem Problem Statement: Both players are given the same string, s Both players have to make substrings using the letters of the string s Stuart has to make words starting with consonants. Kevin has to make words starting with vowels. The game ends when both players have made all possible substrings. output format: Print one line: the name of the winner and their score separated by a space. If the game is a draw, print Draw. Created on Jan 13, 2018 @author: Anonymous3.1415 ''' #splits the given string def get_sub_strings(given_string): string_leangth = len(given_string) return [given_string[i:j+1] for i in xrange(string_leangth) for j in xrange(i, string_leangth)] def minion_game(given_string): split_string = get_sub_strings(given_string) vowels = 0 consonants = 0 for i in xrange(len(split_string)): if split_string[i] in "AEIOU": vowels += 1 else: consonants += 1 if vowels > consonants: print("Kevin %d") % (vowels) elif vowels == consonants: print("draw") else: print("Stuart %d") % (consonants) return given_string = 'BANANA' minion_game(given_string)