Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. bob = set()
  2.  
  3. for i in range(4):
  4. for j in range(4):
  5. bob.add((i,j))
  6.  
  7. print len(bob)
  8.  
  9.  
  10. def get_potential_additions(element_list, parent_list):
  11.  
  12. if len(element_list) == 0:
  13. return parent_list
  14.  
  15. x_vals = [item[0] for item in element_list]
  16. y_vals = [item[1] for item in element_list]
  17.  
  18. potential_adds = filter(lambda item: (item[0] not in x_vals and item[1] not in y_vals), parent_list)
  19.  
  20. return potential_adds
  21.  
  22.  
  23. def get_all_mappings(operating_set, current_list = [], all_groups = []):
  24.  
  25. additions = get_potential_additions(current_list, operating_set)
  26. #print additions
  27.  
  28. if len(additions) == 0:
  29. all_groups.append(tuple(sorted(current_list)))
  30.  
  31. for element in additions:
  32. current_list_copy = list(current_list)
  33. current_list_copy.append(element)
  34. get_all_mappings(additions, current_list_copy, all_groups)
  35.  
  36. return set(all_groups)
  37.  
  38.  
  39. get_all_mappings(list(bob))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement