----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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



>
>
>
> In slow motion and with intermediate variables this is:
>
> Three doors: one has a 1 behind it (thats the car) the other two have a big
> zero.
>
> Doors: random [0 0 1]
>
> whichever door I pick is modelled by
>
> MyDoor: first Doors
>
> Monty then shows me a zero door:
>
> MontyDoor: mimimum Door/2 Door/3
>
> I then select the other of Monty's doors:
>
> MySwappedDoor: Maximim Door/2 Door/3
>
> which is the same as
>
> MySwappedDoor: last sort next Doors
>
> so if MySwappedDoor is a 1, I'm a winner!
>
> Sunanda
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to