Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CelesteComet/bd4ebbe914a6591fff2217d82b3d4ef6 to your computer and use it in GitHub Desktop.
Save CelesteComet/bd4ebbe914a6591fff2217d82b3d4ef6 to your computer and use it in GitHub Desktop.
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