Created
August 20, 2021 14:49
-
-
Save r14152/a96f2eff78f8eddb7b7b4f66e24ebefb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def removeOccuranceFromList(val, lst): | |
return list(filter((val).__ne__, lst)) | |
#struat start with constant | |
def struatMinnion(word): | |
totalCount = 0 | |
vowel = ['A','E','I','O','U'] | |
finalList = [word[i:j] for i in range(len(word)) for j in range(i,len(word)+1) if word[i] not in vowel and word[i:j] != ''] | |
#print("Struat ", finalList) | |
for value in finalList: | |
totalCount += finalList.count(value) | |
finalList = removeOccuranceFromList(value, finalList) | |
return totalCount | |
#kevin start with vowel | |
def kevinMinnion(word): | |
vowel = ['A','E','I','O','U'] | |
totalCount = 0 | |
finalList = [word[i:j] for i in range(len(word)) for j in range(i,len(word)+1) if word[i] in vowel and word[i:j] != ''] | |
#print("Kevin ", finalList) | |
for value in finalList: | |
totalCount += finalList.count(value) | |
finalList = removeOccuranceFromList(value, finalList) | |
return totalCount | |
def minion_game(string): | |
struatCount = struatMinnion(string) | |
kevinCount = kevinMinnion(string) | |
#print(struatCount, kevinCount) | |
if struatCount == kevinCount: | |
print("Draw") | |
return | |
if struatCount > kevinCount: | |
print("Stuart", struatCount) | |
else: | |
print("Kevin", kevinCount) | |
if __name__ == '__main__': |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment