Advertisement
Guest User

Star connections

a guest
May 3rd, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. def other_points(point=None):
  2.     for i in [i for i in range(9) if i != point]:
  3.         yield i
  4.  
  5. def get_connections(points):
  6.     connects = set()
  7.     for i in range(len(points) - 1):
  8.         connects |= connections[f({points[i], points[i + 1]})]
  9.     return connects
  10.  
  11. f = frozenset
  12.  
  13. connections = {f({0, 2}): f({1}), f({0, 6}): f({3}), f({0, 8}): f({4}),
  14.                f({1, 7}): f({4}), f({2, 6}): f({4}), f({2, 8}): f({5}),
  15.                f({3, 5}): f({4})}
  16.  
  17. for start in range(9):
  18.     for end in range(start, 9):
  19.         fs = f({start, end})
  20.         connections[fs] = connections.get(fs, f()) | fs
  21.  
  22. for start in range(9):
  23.     for mid_1 in other_points(start):
  24.         for mid_2 in other_points(mid_1):
  25.             for mid_3 in other_points(mid_2):
  26.                 for end in other_points(mid_3):
  27.                     points = (start, mid_1, mid_2, mid_3, end)
  28.                     if get_connections(points) == set(range(9)):
  29.                         print(points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement