[Jprogramming] Dice rolls
David Vaughan
purpleblues13 at googlemail.com
Tue Oct 11 19:28:14 HKT 2011
Thanks.
Before you sent that, I was messing around with the power conjunction and came up with:
d1=. 1 2 3 4 5 6
(+/%#)7=,d1(+/)^:1 d1
0.166667
Set n in ^:n to rolls-1.
Which method, yours or mine do you think is the better one for speed and space?
On 11 Oct 2011, at 12:14, Raul Miller wrote:
> On Tue, Oct 11, 2011 at 6:48 AM, David Vaughan
> <purpleblues13 at googlemail.com> wrote:
>> I'm trying to work out the probability of any number being rolled by an n-sided die with r rolls. For example, a 6-sided die with 2 rolls, 7 has probability 6/36=1/6.
>
> avg=: +/%#
> avg , 7 = +// 2#,:1+i.6
> 0.166667
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list