Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First, by recursion. solution in Clear category for Card Game by Tinus_Trotyl
def cards(deck, hand):
if hand == []: return True
if type(deck) is int: deck = set((n, n+1) for n in range(deck))
if (hand[0] - 1, hand[0]) in deck: return cards(deck - {(hand[0] - 1, hand[0])}, hand[1:])
if (hand[0], hand[0] + 1) in deck: return cards(deck - {(hand[0], hand[0] + 1)}, hand[1:])
return False
Oct. 4, 2018