Gray code by yanbe

n=input()
print 'Gray code  n=%s'%n
for i in range(2**n):
 i=i^i>>1;b=''
 exec"b='01'[i&1]+b;i>>=1;"*n
 print b

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top