fork download
  1. f = lambda n:[(i^min(i,~i%n)%-2)%n for i in range(n)]
  2.  
  3. for x in range(1, 11): print('%2d: %s' % (x, f(x)))
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
 1: [0]
 2: [0, 1]
 3: [0, 1, 2]
 4: [0, 2, 1, 3]
 5: [0, 3, 2, 1, 4]
 6: [0, 4, 2, 3, 1, 5]
 7: [0, 5, 2, 3, 4, 1, 6]
 8: [0, 6, 2, 4, 3, 5, 1, 7]
 9: [0, 7, 2, 5, 4, 3, 6, 1, 8]
10: [0, 8, 2, 6, 4, 5, 3, 7, 1, 9]