Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/swaab.py
Last active August 29, 2015 14:11
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 zeffii/f8cfc8124079610fbb16 to your computer and use it in GitHub Desktop.
Save zeffii/f8cfc8124079610fbb16 to your computer and use it in GitHub Desktop.
# variations of incomplete cube
import itertools
import random
def shift2(tup):
return tuple(list(tup[-2:]) + list(tup[:-2]))
n = 12
k = list(itertools.product(*[(0, 1)] * n))
items = [i for i in k if sum(i) >= 3 and sum(i) <= 11]
items2 = []
# don't store rotated versions
for i in items:
a = shift2(i)
b = shift2(a)
c = shift2(b)
d = shift2(c)
e = shift2(d)
t = [(op in items2) for op in [i, a, b, c, d, e]]
found_any = any(t)
if not found_any:
items2.append(i)
titems = []
titems2 = []
for i in items2:
if random.random() > 0.8:
titems.append(i)
tup_as_string = ''.join([str(h) for h in i])
converted = int(tup_as_string, 2)
titems2.append(converted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment