From: Matthew Smillie Date: 2006-01-08T04:27:31+09:00 Subject: Re: Dice Roller (#61) On Jan 7, 2006, at 18:32, Christian Neukirchen wrote: > Gavin Kistner writes: > >> On Jan 7, 2006, at 9:55 AM, Gavin Kistner wrote: >>> On Jan 7, 2006, at 5:03 AM, Christian Neukirchen wrote: >>>> "Matthew D Moss" writes: >>>>> Parse tree for: (5d5-4)d(16/d4)+3 >>>> >>>> So what are the maximum and minimum values of this? >>> >>> Max: (5*5+4)*(16/4)+3 = 29*4+3 = 119 >> >> Man, *and* I flipped the sign on that -4. *shakes head sadly* >> >> One more shot. >> >> Min: (5*1-4)*(1)+3 = 1*1+3 = 4 >> Max: (5*5-4)*(16/4)+3 = 21*4+3 = 87 > > I claim 4 and 339. Both (4, 87) and (4, 339) are correct depending on your definition of 'max'. You get the former if you assume maximum rolls for each die, and the latter if you want the maximum possible result of the expression. In any case, the extremal results aren't particularly useful from a testing point of view, as different distributions can have the same extremal points, and you could potentially erroneously pass an incorrect case. For example: 2d2d6 left-associative: (2d2)d6 -> 4d6 -> 24 max right-associative (oops!): 2d(2d6) -> 2d12 -> 24 max But the distributions are different in each case (the latter result could include 2 and 3, for instance). matthew smillie.