I have a set of products that must be scheduled. There are P products each indexed from 1 to P. Each product can be scheduled into a time period 0 to T. I need to construct
public static IList> Permutation(ImmutableList> dimensions)
{
IList> result = new List>();
Step(ImmutableList.Create(), dimensions, result);
return result;
}
private static void Step(ImmutableList previous,
ImmutableList> rest,
IList> result)
{
if (rest.IsEmpty)
{
result.Add(previous);
return;
}
var first = rest[0];
rest = rest.RemoveAt(0);
foreach (var label in first)
{
Step(previous.Add(label), rest, result);
}
}