Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Card Game by mortonfox
from collections import Counter
def cards(deck, hand):
numbers = Counter(hand)
for card in range(deck):
for num in range(card, card + 2):
if numbers[num]:
numbers[num] -= 1
break
return sum(numbers.values()) == 0
if __name__ == '__main__':
print("Example:")
print(cards(5, [2, 0, 1, 2]))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert cards(5, [2, 0, 1, 2]) == False
assert cards(10, [9, 9, 6, 6]) == True
assert cards(10, [11]) == False
print("Coding complete? Click 'Check' to earn cool rewards!")
Sept. 21, 2018
Comments: