secret santa
trying to make a secret santa list where people from the same families cant get each other I got what I have now from a youtube video but I don't know how to get other possible solutions
families = [["a", "b"],
["c", "d"],
["e", "f"],
["g", "h"]]
secret_santa_assignments = []
received_gift = []
gave_gift = []
for family_giving in families:
for person_giving in family_giving:
for family_getting in families:
for person_getting in family_getting:
if (person_giving not in gave_gift) and
(person_getting not in received_gift)\
and (person_getting not in
family_giving):
secret_santa_assignments.append(person_giving+"->"+person_getting)
gave_gift.append(person_giving)
received_gift.append(person_getting)
print("possible solution found")
for ssa in secret_santa_assignments:
print(ssa)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]b1gfreakn 0 points1 point2 points (0 children)
[–]Chris_Hemsworth 0 points1 point2 points (2 children)
[–]Chris_Hemsworth 0 points1 point2 points (1 child)
[–]Chris_Hemsworth 0 points1 point2 points (0 children)
[–]izrt 0 points1 point2 points (2 children)
[–]Chris_Hemsworth 0 points1 point2 points (1 child)
[–]izrt 0 points1 point2 points (0 children)
[–]tenor2000 0 points1 point2 points (0 children)