Jump to content

Dice game probabilities: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 911:
computed: p1 = 5d10, p2 = 6d7, prob = 7562343938 / 11764900000 = 0.64278862871763
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>ClearAll[GetProbability]
GetProbability[{dice1_List, n_Integer}, {dice2_List, m_Integer}] :=
Module[{a, b, lena, lenb},
a = Tuples[dice1, n];
a = Plus @@@ a;
lena = a // Length;
a = Tally[a];
a[[All, 2]] /= lena;
b = Tuples[dice2, m];
b = Plus @@@ b;
lenb = b // Length;
b = Tally[b];
b[[All, 2]] /= lenb;
Total[If[#[[1, 1]] > #[[2, 1]], #[[1, 2]] #[[2, 2]], 0] & /@
Tuples[{a, b}]]
]
GetProbability[{Range[4], 9}, {Range[6], 6}]
GetProbability[{Range[10], 5}, {Range[7], 6}]</lang>
{{out}}
<pre>48679795/84934656
3781171969/5882450000</pre>
 
=={{header|Nim}}==
1,111

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.