Sum of roll of N dice
|
05-11-2018, 12:19 PM
Post: #42
|
|||
|
|||
RE: Sum of roll of N dice
(05-11-2018 09:52 AM)brickviking Wrote: You guys can have your probability-based solutions. I do have a perfectly working version of the program from the DUP 6. SWAP post that I've extended for n-sided dice. Dies. Dice... eh, whatever: Your generalized solution (and the base-6 idea from Jim Horn) (05-02-2018 07:01 AM)Jim Horn Wrote: If you roll N six sided dice and put them next to each other and write down the values they show *minus 1* each, you'll get an N digit integer in base 6. All such 6^N integers are equally likely for fair dice. So, just find a random number from 0 to (6^N)-1, convert to base 6, add the sum of its digits plus N (to correct the "subtract 1 from each digit") and there you go: the sum of the six rolled dice with only one random number generation. are beautifully elegant- maybe the best there is! In my own problem solving I do struggle with knowing when is "good enough" and when to keep looking for a more elegant algorithm. Sometimes I learn new and equally cool things when I continue a little further down a path, even if I have a working solution in hand. We are all explorers, and serendipity is waiting just around the corner. 17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)