|
|
@ -42,46 +42,73 @@ for aller, cont in allerthing.items(): |
|
|
|
while(thing in allfood): |
|
|
|
while(thing in allfood): |
|
|
|
allfood.remove(thing) |
|
|
|
allfood.remove(thing) |
|
|
|
|
|
|
|
|
|
|
|
#print(len(allfood)) |
|
|
|
print(len(allfood)) |
|
|
|
|
|
|
|
|
|
|
|
ignorefoods = set( [food for food in allfood] ) |
|
|
|
ignorefoods = set( [food for food in allfood] ) |
|
|
|
|
|
|
|
|
|
|
|
seenaller = set() |
|
|
|
seenaller = set() |
|
|
|
seenfood = set() |
|
|
|
seenfood = set() |
|
|
|
|
|
|
|
|
|
|
|
thing = dict() |
|
|
|
thing = dd(set) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getFood(foodList, exclude=set()): |
|
|
|
|
|
|
|
food = set(foodList) |
|
|
|
|
|
|
|
for ignore in ignorefoods: |
|
|
|
|
|
|
|
food.discard(ignore) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ex in exclude: |
|
|
|
|
|
|
|
food.discard(exclude) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return food |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
takenAllers = set() |
|
|
|
for i, food in enumerate(foodlist): |
|
|
|
for i, food in enumerate(foodlist): |
|
|
|
|
|
|
|
food = getFood(food) |
|
|
|
aller = allerlist[i] |
|
|
|
aller = allerlist[i] |
|
|
|
# why is there no NAND? :( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for j, food2 in enumerate(foodlist): |
|
|
|
if( len(food) == 1 and len(aller) == 1 ): |
|
|
|
if(i == j): |
|
|
|
if( not list(aller)[0] in takenAllers ): |
|
|
|
continue |
|
|
|
thing[list(food)[0]] = list(aller)[0] |
|
|
|
|
|
|
|
ignorefoods.add(list(food)[0]) |
|
|
|
|
|
|
|
|
|
|
|
aller2 = allerlist[j] |
|
|
|
elif(len(food) > 1 and len(aller) > 1): |
|
|
|
commonaller = set(aller) & set(aller2) |
|
|
|
for j, food2 in enumerate(foodlist): |
|
|
|
|
|
|
|
if(i == j): |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
commonfood = set(food) & set(food2) |
|
|
|
food2 = getFood(food2) |
|
|
|
|
|
|
|
aller2 = allerlist[j] |
|
|
|
|
|
|
|
|
|
|
|
for ignore in ignorefoods: |
|
|
|
commonFood = list(food & food2) |
|
|
|
commonfood.discard(ignore) |
|
|
|
commonAller = list(set(aller) & set(aller2)) |
|
|
|
|
|
|
|
|
|
|
|
for seen in seenfood: |
|
|
|
for ignore in ignorefoods: |
|
|
|
commonfood.discard(seen) |
|
|
|
while(ignore in commonFood): |
|
|
|
|
|
|
|
commonFood.remove(ignore) |
|
|
|
|
|
|
|
|
|
|
|
for al in commonaller: |
|
|
|
for ignore in takenAllers: |
|
|
|
if(al in seenaller): |
|
|
|
while(ignore in commonAller): |
|
|
|
continue |
|
|
|
commonAller.remove(ignore) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(commonFood, commonAller) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(len(commonFood) >= 1 and len(commonAller) >= 1): |
|
|
|
|
|
|
|
if( not commonAller[0] in takenAllers ): |
|
|
|
|
|
|
|
thing[commonFood[0]] = commonAller[0] |
|
|
|
|
|
|
|
ignorefoods.add(commonFood[0]) |
|
|
|
|
|
|
|
takenAllers.add(commonAller[0]) |
|
|
|
|
|
|
|
|
|
|
|
cfList = list(commonfood) |
|
|
|
|
|
|
|
caList = list(commonaller) |
|
|
|
|
|
|
|
#breakpoint() |
|
|
|
|
|
|
|
if( len(commonfood) == 1 and len(commonaller) == 1 ): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thing[cfList[0]] = caList[0] |
|
|
|
|
|
|
|
seenfood.add(cfList[0]) |
|
|
|
|
|
|
|
seenaller.add(caList[0]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(thing) |
|
|
|
print(thing) |
|
|
|
|
|
|
|
sortedthing = sorted(thing.items(), key = lambda kv:(kv[1], kv[0])) |
|
|
|
|
|
|
|
print(sortedthing) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
part2 = "" |
|
|
|
|
|
|
|
for i, sort in enumerate(sortedthing): |
|
|
|
|
|
|
|
part2 += f"{sort[0]}" |
|
|
|
|
|
|
|
if( i < len(sortedthing)-1 ): |
|
|
|
|
|
|
|
part2 += "," |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("###########", part2) |
|
|
|