Skip to main content
Commonmark migration
Source Link

Python - 54

##Python - 54## BasedBased off of an algorithm from the reference given in the challenge:

for i in range(2**n):print'{1:0{0}b}'.format(n,i>>1^i)

Ungolfed:

# For each of the possible 2**n numbers...
for num in range(2**n):
    gray = num>>1 ^ num
    
    # Print in binary and pad with n zeros.
    print '{1:0{0}b}'.format(grey)

##Python - 54## Based off of an algorithm from the reference given in the challenge:

for i in range(2**n):print'{1:0{0}b}'.format(n,i>>1^i)

Ungolfed:

# For each of the possible 2**n numbers...
for num in range(2**n):
    gray = num>>1 ^ num
    
    # Print in binary and pad with n zeros.
    print '{1:0{0}b}'.format(grey)

Python - 54

Based off of an algorithm from the reference given in the challenge:

for i in range(2**n):print'{1:0{0}b}'.format(n,i>>1^i)

Ungolfed:

# For each of the possible 2**n numbers...
for num in range(2**n):
    gray = num>>1 ^ num
    
    # Print in binary and pad with n zeros.
    print '{1:0{0}b}'.format(grey)
Source Link

##Python - 54## Based off of an algorithm from the reference given in the challenge:

for i in range(2**n):print'{1:0{0}b}'.format(n,i>>1^i)

Ungolfed:

# For each of the possible 2**n numbers...
for num in range(2**n):
    gray = num>>1 ^ num
    
    # Print in binary and pad with n zeros.
    print '{1:0{0}b}'.format(grey)