The method I'm trying to implement is like
/*
e.g. {1, 2, 3}, k = 2
--->
[ (), () ],
[ (1), () ],
[ (), (1) ],
[ (2), () ],
[ (), (2) ],
[ (3), () ],
[ (), (3) ],
[ (1), (2) ],
[ (2), (1) ],
[ (1), (3) ],
[ (3), (1) ],
[ (2), (3) ],
[ (3), (2) ],
[ (1,2), () ],
[ (2,3), () ],
[ (1,3), () ],
[ (), (1,2) ],
[ (), (1,3) ],
[ (), (2,3) ],
[ (1,2), (3) ],
[ (2,3), (1) ],
[ (1,3), (2) ],
[ (3), (1,2) ],
[ (1), (2,3) ],
[ (2), (1,3) ],
[ (1,2,3), () ],
[ (), (1,2,3,) ]
*/
public static List<List<T>> SpecialPartition<T>(this List<T> source, int k)
{
throw new NotImplementedException();
}
I'm first wondering whether there's some known (Donald Knuth?) algorithm for doing this. Note how the order of the buckets matters, e.g. I consider (1,2), (3)
and (3), (1,2)
as separate results.