Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6 line solution in Clear category for Card Game by Sim0000
def cards(deck, hand):
last = 0
for card in sorted(hand):
last = max(last + 1, card)
if last > min(card + 1, deck): return False
return True
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
assert cards(3, [0, 1, 1]) == False
assert cards(10, [3, 3, 5, 6, 6, 7]) == True
assert cards(8, [4, 4, 5, 6, 7]) == True
assert cards(7, [4, 4, 5, 6, 7]) == False
assert cards(4, [0, 0]) == False
assert cards(4, [2, 2]) == True
assert cards(4, [4, 4]) == False
assert cards(4, [2, 2, 2]) == False
assert cards(4, [1, 1, 2, 2]) == False
assert cards(4, [2, 2, 3, 3]) == False
assert cards(4, [0, 1, 2, 3, 3]) == False
assert cards(4, [1, 1, 2, 3, 4]) == False
assert cards(4, [0, 1, 2, 3, 4]) == False
assert cards(4, [1, 1, 2, 3, 3]) == False
assert cards(10, [1, 1, 2, 3, 4, 5, 6, 7, 7]) == False
print("Coding complete? Click 'Check' to earn cool rewards!")
Sept. 28, 2018
Comments: