[TIB] Re: Complete!


[Prev][Next][Index][Thread]

[TIB] Re: Complete!



> Also note that RandInt(1,6,D) would create a list with all the tosses,
> although I'm not sure if it would necessarily be quicker, since you still
> need to search for successes.  There's probably a quicker way, but perhaps
> it doesn't matter.

I'm not sure about the 86, but 83 style, I'd do this:

Note:
 D	= number of rolls
 N	= minimum number to "succeed"
 S	= number of successes
 ->	= "store" command
 =>	= greater than or equal to symbol
 lROLL	= the list named ROLL, you'll have to change that to 86 syntax.

RandInt(1,6,D)->lROLL
sum(lROLL=>N)->S

Check all elements of the list against the constant N. This generates a
list (with the same length as lROLL) consisting of 0's and 1's. A 0 means
the corresponding element of lROLL is smaller then N, while 1 means that
the element of the list is greater then or equal to N. Then the sum of the
new list is calculated, which is the number of rolls that satisfy =>N.

Rob van Wijk

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!




Follow-Ups: References: