Anonymous user
Dice game probabilities: Difference between revisions
m
→optimized: increased the displayed digits, changed a comment.
m (Rust - reformatted with rustfmt) |
m (→optimized: increased the displayed digits, changed a comment.) |
||
Line 1,761:
This REXX version is an optimized and reduced version of the first part of the 1<sup>st</sup> REXX example.
<lang rexx>/*REXX pgm computes and displays the probabilities of a two─player S─sided, N─dice game.*/
numeric digits 100 /*
call game 9 4, 6 6 /*1st player: 9 dice, 4 sides; 2nd player: 6 dice, 6 sides*/
call game 5 10, 6 7 /* " " 5 " 10 " " " 6 " 7 " */
Line 1,780:
do j=w.1 to w.1*s.1; winP= winP + p.1.j * low.j
end /*j*/
say 'The probability for first player to win is '
say /*
return /*
/*──────────────────────────────────────────────────────────────────────────────────────*/
prob: procedure; parse arg n,s,,@ $; #.= 0; pow= s**n
Line 1,795:
Player 1 has 9 dice with 4 sides each.
Player 2 has 6 dice with 6 sides each.
The probability for first player to win is 57.
Player 1 has 5 dice with 10 sides each.
Player 2 has 6 dice with 7 sides each.
The probability for first player to win is 64.
</pre>
|