Forum Discussion
Count how many pairs of dice sum >= 7?
- Jan 17, 2025
Absolutely. REDUCE can be used to iterate through the number of dice, adding the SEQUENCE of sides (vertical vector) to the previous transposed results using TOROW (horizontal vector). The lambda definition could be something like this:
=LAMBDA(num_of_sides,num_of_dice,operator,value, LET( n, SEQUENCE(num_of_sides), m, IF(num_of_dice = 1, n, REDUCE(n, SEQUENCE(num_of_dice - 1), LAMBDA(a,i, TOROW(a) + n))), t, CHOOSE( XMATCH(operator, {"<";"<=";"<>";"=";">";">="}), m < value, m <= value, m <> value, m = value, m > value, m >= value ), SUM(--t)/COUNTA(t) ) )
You could name it DICEPROBλ, for example, then use it as follows:
=DICEPROBλ(6,2,">=",7)
Or:
=DICEPROBλ(6,3,">",9)
Or:
=DICEPROBλ(6,7,"<",25)
And so on and so forth.
This function returns the probability. If you want it to return the count instead, simply remove /COUNTA(t) from the last line of the function definition.
Note: the PERMλ function was a generic permutation generator I had saved from a previous project. It works but is not the most efficient method for this scenario. Thanks for prompting me to rethink it! 😉
To find how many pairs of dice have a sum greater than or equal to 7, we need to consider all possible outcomes when rolling two dice. Each die has 6 sides, so there are 6 × 6 = 36 possible outcomes.
Now, we need to count how many of these outcomes give a sum of 7 or greater. The possible sums and their corresponding pairs are:
- Sum = 7: (1, 6), (2, 5), (3, 4), (4, 3), (5, 2), (6, 1) — 6 outcomes
- Sum = 8: (2, 6), (3, 5), (4, 4), (5, 3), (6, 2) — 5 outcomes
- Sum = 9: (3, 6), (4, 5), (5, 4), (6, 3) — 4 outcomes
- Sum = 10: (4, 6), (5, 5), (6, 4) — 3 outcomes
- Sum = 11: (5, 6), (6, 5) — 2 outcomes
- Sum = 12: (6, 6) — 1 outcome
Now, adding them up:
6 (for sum 7) + 5 (for sum 8) + 4 (for sum 9) + 3 (for sum 10) + 2 (for sum 11) + 1 (for sum 12) = 21 outcomes.
So, there are 21 pairs of dice that sum to 7 or greater.