[REBOL] Re: A Rebol Challenge. The Monty Hall Puzzle IN 0 BY TES
From: joel::neely::fedex::com at: 17-Dec-2001 15:44
Hi, Reichart,
Just a minor quibble and a major coincidence...
Reichart wrote:
...
> w: 100 print [loop w [w: w - first random [0 0 1]]]
>
> Which, although a VERY COOL example of Rebol, is not a good example of the
> problem.
>
> This exact same problem in other languages would be just:
> Matlab: sum(rand(100,1)>1/3)
> C: for(int i=0,j=0;i<100;i++)j+=rand(3)>1;cout<<j;
> In Perl: $i=0;$j=0;for(;$i<100;$i++){$j+=rand(3)>1;}print $j
> Rebol: w: 100 print [loop w [w: w - first random [0 0 1]]]
>
Actually, it can be written in Perl as
for(1..100){$j+=rand(3)>1}print $j
dropping 17 bytes from 51 to 34 (concidentally 2/3!!!)
-jn-