Nathann,
A simple recursively defined pure Python generator for the binary reverse Gray 
code
is below.  The elements of the code are represented as lists whose elements are 
0s
and 1s.

Robert Campbell

def GC2(n,reverse=0):
        if(n==0): 
                yield []
        elif(reverse==0):
                for elt in GC2(n-1,0): yield ([0] + elt)
                for elt in GC2(n-1,1): yield ([1] + elt)
        else:
                for elt in GC2(n-1,0): yield ([1] + elt)
                for elt in GC2(n-1,1): yield ([0] + elt)



>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to