Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: A Rebol Challenge. The Monty Hall Puzzle

From: rotenca:telvia:it at: 16-Dec-2001 14:11

----- Original Message ----- From: <[SunandaDH--aol--com]> To: <[rebol-list--rebol--com]> Sent: Sunday, December 16, 2001 12:52 PM Subject: [REBOL] Re: A Rebol Challenge. The Monty Hall Puzzle
> Hi Reichart. > > > > But maybe you can do better in Rebol. I don't see a way to off the top
of
> > my head. Note that if we're just comparing the core computation, the > matlab > > is barely three lines. (The "o" variable is not strictly needed, but I
am
> > including it anyway to explicitly construct the > > door-picked-by-Monty.) > > Here's my attempt. It runs a simulated Monty 500 times. > I get a "length" of 142 (length? mold load %doors.r), but I don't have the > same text message as you and the "external" length could be shorter by > one-lining it all and reducing the variables to W and N. > > The core calculation is just one line, but I'm using a different algorithm. > > rebol [] > Win: 0 n: 0 > loop 500 [ > n: n + 1 > win: win + last sort next random [0 0 1] > ] > Print ["Win%" win * 100 / n]
Beautiful! You can remove the n + 1: Win: 0 n: 500 print ["Win%" 100 / n * loop n [win: win + last sort next random [0 0 1]]] --- Ciao Romano