I have 10,000 baskets. In each basket, I have 10 food objects, no repetitions.
I need to group baskets in groups where all baskets in the group have >=6 of the same objects within them, with no repetitions in any group. Basically, if a group has basket1, basket2, basket33, basket 123, then no other groups will have them.
When I try to do it with combinations, I end up with many redundant groups.
from typing import Generic, TypeVar, List
import random
from uuid import uuid4
import attr
T = TypeVar("T")
food = ['apple', 'banana','grapes','orange','potato','kiwi','pomegranate','blueberry','strawberry','cantalope','honeydew','papaya','mango','raspberry',
'celery','carrot','potato','raddish','lettuce','tomato','garlic','onion','cabbage','corn','shallot','peas','squash','broccoli','spinach']
#'pasta','sugar','flour','honey','salt','pepper','corn starch','baking soda','cinnamon','paprika','butter','cream','chocolate']
@attr.dataclass
class Basket(Generic[T]):
items: List[T]
volume: int
id: str = attr.ib(factory=lambda: str(uuid4()))
#Generate baskets
basket_names = [f"basket{i}" for i in range(1, 10001)]
baskets: List[Basket[str]] = [
Basket(items=random.sample(food, 10), volume=random.randint(0, 1000), id=name)
for name in basket_names
]