Advertisement
eswald

Hole Punch

Oct 7th, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. positions = [0, 1, 2, 5, 6, 7, 10, 11, 12]
  2. rotations = [
  3.     [0, 1, 2, 3, 4, 5, 6, 7, 8],
  4.     [2, 5, 8, 1, 4, 7, 0, 3, 6],
  5.     [8, 7, 6, 5, 4, 3, 2, 1, 0],
  6.     [6, 3, 0, 7, 4, 1, 8, 5, 2],
  7. ]
  8.  
  9. shapes = set()
  10. for n in range(1, 2**9):
  11.     rotated = []
  12.     for rot in rotations:
  13.         shape = 0
  14.         for bit, pos in zip(rot, positions):
  15.             if n & (1 << bit):
  16.                 shape += 1 << pos
  17.        
  18.         while shape and not (shape & 1):
  19.             shape >>= 1
  20.         rotated.append(shape)
  21.    
  22.     shapes.add(min(rotated))
  23.  
  24. for shape in sorted(shapes):
  25.     print bin(shape)
  26.  
  27. print len(shapes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement