Skip to content

Instantly share code, notes, and snippets.

@gilleain
Created May 20, 2009 14:54
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 gilleain/114856 to your computer and use it in GitHub Desktop.
Save gilleain/114856 to your computer and use it in GitHub Desktop.
def bin(x, count=8):
return map(lambda y: (x>>y)&1, range(count-1, -1, -1))
def pvrSequenceToMatrix(X):
return [bin(x, len(X)) for x in X]
def generateAllPVRSequences(xs, X, l, n, m):
if l == n:
xs.append(X)
else:
if (l > 0): minimum = X[l - 1]
else: minimum = 1
for i in range(minimum, m):
generateAllPVRSequences(xs, X + [i], l + 1, n, m)
n = int(sys.argv[1])
m = 2 ** n
xs = []
generateAllPVRSequences(xs, [], 0, n, m)
for X in xs:
print pvrSequenceToMatrix(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment