I am struggling with this algorithm that I need to write. I am using C #.
Say I have List<Bag>, and I have List<Lunch>. I need to write an algorithm that will list all the permutations of dinners in all packages.
For example, let's say that there are 3 lunches and 2 bags:
// Permutation 1
Bag 1, Lunch 1
Bag 2, Lunch 1
// Permutation 2
Bag 1, Lunch 1
Bag 2, Lunch 2
// Permutation 3
Bag 1, Lunch 1
Bag 2, Lunch 3
// Permutation 4
Bag 1, Lunch 2
Bag 2, Lunch 1
// Permutation 5
Bag 1, Lunch 2
Bag 2, Lunch 2
// Permutation 6
Bag 1, Lunch 2
Bag 2, Lunch 3
// Permutation 7
Bag 1, Lunch 3
Bag 2, Lunch 1
// Permutation 8
Bag 1, Lunch 3
Bag 2, Lunch 2
// Permutation 9
Bag 1, Lunch 3
Bag 2, Lunch 3
Two permutations Bag 1 Lunch 1 and Bag 2 Lunch 2and Bag 1 Lunch 2 and Bag 2 Lunch 1different from each other, because the bags have different capacity, so they should both be listed.
The number of bags and dinners can be any number.
I created a class called BagLunchthat contains a pair with a bag and lunch. The list of examples above will be stored in List<BagLunch>.
Thank.