Unique Unordered Dice Outcomes
Problem statement
A die has faces labeled from 1 through faces and is rolled rolls times. Return every distinct outcome when roll order does not matter.
Represent each outcome as a nondecreasing array of face values. Return all outcomes in lexicographic order. Repeated face values are allowed. When rolls = 0, return one empty outcome.
Function
unorderedDiceOutcomes(faces: int, rolls: int) → int[][]Examples
Example 1
faces = 3rolls = 2return = [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]Each pair is nondecreasing, so order-equivalent results such as [1,2] and [2,1] appear only once.
Example 2
faces = 2rolls = 0return = [[]]There is exactly one way to make zero rolls: the empty outcome.
Constraints
1 <= faces <= 150 <= rolls <= 10- The number of returned outcomes is at most
100000