Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bob = set()
- for i in range(4):
- for j in range(4):
- bob.add((i,j))
- print len(bob)
- def get_potential_additions(element_list, parent_list):
- if len(element_list) == 0:
- return parent_list
- x_vals = [item[0] for item in element_list]
- y_vals = [item[1] for item in element_list]
- potential_adds = filter(lambda item: (item[0] not in x_vals and item[1] not in y_vals), parent_list)
- return potential_adds
- def get_all_mappings(operating_set, current_list = [], all_groups = []):
- additions = get_potential_additions(current_list, operating_set)
- #print additions
- if len(additions) == 0:
- all_groups.append(tuple(sorted(current_list)))
- for element in additions:
- current_list_copy = list(current_list)
- current_list_copy.append(element)
- get_all_mappings(additions, current_list_copy, all_groups)
- return set(all_groups)
- get_all_mappings(list(bob))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement