on writing a while loop for rolling two dice

Andrew Jaffe a.h.jaffe at gmail.com
Sat Sep 11 06:12:20 EDT 2021


On 11/09/2021 10:09, dn via Python-list wrote:
> 
> 
> 
> The stated requirement is: "I'd like to get the number of times I
> tried". Given such: why bother with returning any of the pairs of values?

Indeed, if that's the requirement, then you can do even better, noting 
that the probability of getting a matched pair is 1/6 (6 matches out of 
6*6 possibilities). So the answer to the problem is exactly the same as 
rolling a single die until you get any particular number (e.g., 1).

This is somewhat easier to simulate than the two-dice problem (and the 
number of throws until a match is also a known, analytic distribution 
that you could sample from, but this is probably easier).




More information about the Python-list mailing list