Sorry, this does not work.
#/.~ /:~2 toss3 100#3
30 24 46
#/.~ /:~2 toss3 1000#3
246 243 511
The method you use skews uniform distribution. With different base and
larger y skew will be more difficult to notice, but it still will be there.
(That's what I meant when I mentioned 'pain')
Here's a more tacit version with repetitions
toss3=: 4 : 0"0
n=. #y=. ((>.x^.y) # x) #: y-1
if. n > i=. >:y (> i. 1:) r=. ?y+1 do.
r=. (i{.r) , ? (n-i) # x end.
x#.r
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm