SPUG: Stick Riddle

Brian Hatch spug at ifokr.org
Wed Jan 1 18:58:20 CST 2003

> In his college course, he came up with the answer of 50% probability. I 
> wrote the attached Perl script to simulate this, and constently get 38%, 
> assuming the second split is done on the larger piece.

Don't make assumptions.  Instead, use rand to generate two numbers
between 0 and 100, and have those be the 'break points'.  You then
determine the length of the three pieces from that.  See if that
gives you more accurate* results.

* for differing values of 'accurate'.

Brian Hatch                  Inside every old person
   Systems and                is a young person wondering
   Security Engineer          what the hell happened.

Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://mail.pm.org/archives/spug-list/attachments/20030101/7554e557/attachment.bin

More information about the spug-list mailing list