-5
$\begingroup$

I'm working on a personal project and came across an algorithm problem which stumped me. I need to know whether a user has given my program the correct parameters to create the amount of random combinations they're asking for. Without getting too much into detail, it essentially boils down to this:

An infinite number of children are arriving to Math StackExchange HQ for tours and meals.

Each child can choose one item from each category of Sandwiches, Fruits, and Chips (for a total of 3 items).

You have 50 PB&J, 40 turkey, and 10 bologna sandwiches. You also have 90 bananas and 10 apples. And finally, 25 each of ranch, nacho, vinegar, and plain chips.

If each child must take a unique combination of items, what is the greatest number of children can you feed before repeating a meal?

  • The tricky part is, when a child removes an item, it can no longer be used in future combinations. For example, there are only 10 apples, but 12 possible combinations that involve an apple. Therefore, apples have become a limiting factor.
  • What if there are multiple categories unbalanced in that way?
  • What if there were $T$ categories, each having 100 items divided into $T_n$ subcategories with minimum item counts of $m$?
  • I need to generalize an expression to calculate the maximum number of permutations when categories and subcategories are subject to change.
$\endgroup$
3
  • $\begingroup$ $3$ types of category-1, $2$ types of category-2, $4$ types of category-3. Also, you have to be careful that (for example) for each category-1 type, there are at least $(2 \times 4)$ items of that type. Similar considerations for each category-2 type and for each category-3 type. $\endgroup$ Commented Nov 22, 2021 at 0:20
  • $\begingroup$ Hello, thank you for your reply. What's tripping me up is when a child removes an item, it can no longer be used in future combinations. For example, there are only 10 apples, but 12 possible combinations that involve an apple. Therefore, apples have become a limiting factor. How can I adjust for situations like that? My data set has many "subcategories" with just a few items. $\endgroup$
    – Claytone
    Commented Nov 22, 2021 at 3:24
  • $\begingroup$ Normally, you would surmise that you have $3 \times 2 \times 4 = 24$ distinct meals, before you repeat. However, $12$ of those meals would require an apple, and you only have $10$ apples. Therefore, after $(24 - 2 = 22)$ distinct meals, you find that you have used $12$ bananas and $10$ apples. Then, since you are out of apples, any subsequent meals will have to inlcude a banana. Therefore, after $22$ meals, you must repeat a combination. $\endgroup$ Commented Nov 22, 2021 at 6:02

1 Answer 1

0
$\begingroup$

Maybe not a satisfying answer, but I think this question isn't fully specified as stated, because it's ambiguously asked.

For example, suppose you have only 2 categories: Fruits and Drinks and you have the following supply:

Fruits = {Apple, Apple, Apple, Pear} and Drinks = {Juice, Juice, Juice, Milk}

Given this pantry and your set up, do you want the answer to be 1, 2 or 3?

  • It might be 1 because the first child might select {Apple,Juice} and then the second child also asks for {Apple,Juice} even though there was a different, unused combination available.
  • It might be 2 because the first child might select {Pear,Milk} at which point the only combination available is {Apple,Juice} so you can only feed 2 children.
  • It might be 3 because you can give out {Apple,Juice}, {Apple,Milk} and {Pear,Juice} before the only option left is {Apple,Juice}.

Setting this up as a sequence I think makes it ambiguous what you're trying to ask.

My guess is you don't want the answer to be 1, because then it would always be 1 whenever there was the possibility of duplicates. The difference between 2 and 3 is basically whether you're looking for "the most meals I could serve" or "the least meals I might serve" before duplication.

$\endgroup$
1
  • $\begingroup$ Hello! Option 3 was my intention, sorry for the ambiguity. I've edited my question. $\endgroup$
    – Claytone
    Commented Nov 30, 2021 at 16:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .