------ art_5624_31398283.1191160961804 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/9/28, Ruby Quiz <james / grayproductions.net>: > > You just did some probability calculations, and don't know if the answers > are > correct. So you write a program to verify the results. If you have eight > dice, > and throw them all at once, what is the probability that there are AT > LEAST > three fives? Try to write a program that find out the "number of > desirable > outcomes" / "number of possible outcomes" by iterating through all the > possible > outcomes of the dice throw. Hi, My solution can be found at http://pastie.caboo.se/102192 #At least 3 fives from 8 dice: $ time ./rq141_probableiterations_rafc.rb 8 3 Number of desirable outcomes is 226491 Number of possible outcomes is 1679616 Probability is 0.134846893575674 real 0m20.526s user 0m18.449s sys 0m2.060s #It can do non-cubic dice: at least 2 fives from a d10, 2 d6's and one d20: $ ./rq141_probableiterations_rafc.rb -d,2d6,d20 -s 2 1 [1, 1, 1, 1] 889 [2, 2, 3, 9] 1777 [3, 3, 5, 17] 2665 [4, 5, 2, 5] <