Is there a formulaic way to get all the pair combinations for dice results?

60 Views Asked by At

If I rolled 4d6 and get [1,2,3,4] you’d have 6 combinations of 2 but 3 combination pairs of

[1,2][3,4]  
[2,3][1,4]
[1,3][2,4]

I want to come up with a way to get this result when given the number of dice, the number of sides on each die, and the number of dice per cluster. I want to be able to generate the pairs, not the number of pairs. Maybe something like a cartesian product could help?

Edits:

I suppose if you have {a,a,a,a} the pairs would just all be {a,a}

if you have {a,a,a,b} the pairs would be {a,a} and {a,b}

if you have {a,a,b,c} the pairs would be {a,a},{a,b},{a,c},{b,c}

if you have {a,b,c,d} the pairs would be {a,b},{a,c},{a,d},{b,c},{b,d},{c,d}