Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def other_points(point=None):
- for i in [i for i in range(9) if i != point]:
- yield i
- def get_connections(points):
- connects = set()
- for i in range(len(points) - 1):
- connects |= connections[f({points[i], points[i + 1]})]
- return connects
- f = frozenset
- connections = {f({0, 2}): f({1}), f({0, 6}): f({3}), f({0, 8}): f({4}),
- f({1, 7}): f({4}), f({2, 6}): f({4}), f({2, 8}): f({5}),
- f({3, 5}): f({4})}
- for start in range(9):
- for end in range(start, 9):
- fs = f({start, end})
- connections[fs] = connections.get(fs, f()) | fs
- for start in range(9):
- for mid_1 in other_points(start):
- for mid_2 in other_points(mid_1):
- for mid_3 in other_points(mid_2):
- for end in other_points(mid_3):
- points = (start, mid_1, mid_2, mid_3, end)
- if get_connections(points) == set(range(9)):
- print(points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement