Calculate all combinations of a series
问题 I have a list of items, and each item has a quantity. var items = { 1: 12, // we have 12 x item1 2: 1, // we have 1 x item2 3: 1, 4: 7, 5: 2, 6: 2 }; Alternatively this could be viewed as: var items = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 6, 6]; How would you go about obtaining a list of every combination of these items, keeping in mind that the order is entirely unimportant (and hence [1,2,3] == [3,2,1] ), and that not every item has to exist in the result. I