Created
April 13, 2018 00:08
-
-
Save CelesteComet/bd4ebbe914a6591fff2217d82b3d4ef6 to your computer and use it in GitHub Desktop.
This file contains 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 googleCard(cards): | |
end = None | |
dic = {} | |
for card in cards: | |
currentCard = card | |
if end is None: | |
end = currentCard + 5 | |
if currentCard == end: | |
# check the stack | |
theNeededFrequency = dic.keys()[0] | |
mBool = all(value == theNeededFrequency for value in dic.values()) and len(dic) >= 5 | |
if mBool is False: | |
return False | |
else: | |
dic = {} | |
dic[currentCard] = 1 | |
end = currentCard + 5 | |
continue | |
if bool(dic) is False or dic.get(currentCard - 1) >= 1 or bool(dic.get(currentCard)): | |
if dic.get(currentCard) is None: | |
dic[currentCard] = 1 | |
else: | |
dic[currentCard] = dic.get(currentCard) + 1 | |
else: | |
return False | |
# check the stack | |
theNeededFrequency = dic[dic.keys()[0]] | |
mBool = all(value == theNeededFrequency for value in dic.values()) and len(dic) >= 5 | |
if mBool is False: | |
return False | |
else: | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment