Skip to content

Instantly share code, notes, and snippets.

@pberkes
Created January 28, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pberkes/b677a08758e0806f069beeaf9b0383cd to your computer and use it in GitHub Desktop.
Save pberkes/b677a08758e0806f069beeaf9b0383cd to your computer and use it in GitHub Desktop.
def find_sets3(cards, indices=None):
nd, n = cards.shape
c0 = cards[0, :]
if indices is None:
indices = numpy.arange(n)
groups = [(c0 == f).nonzero()[0] for f in range(nfeatures)]
# equals
solequal = []
for g in groups:
if len(g) < 3: continue
solequal += find_sets3(cards[1:nd, g], indices[g])
# different
soldiff = [(indices[i0], indices[i1], indices[i2])
for i0 in groups[0] for i1 in groups[1] for i2 in groups[2]
if is_set(cards, (i0, i1, i2))]
return solequal + soldiff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment