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 IN 0 BY TES

From: reichart:prolific at: 17-Dec-2001 10:24

There are some pretty cool examples here! What is really nice about this little "detour" is that we are all learning some interesting interpretations of the Rebol words, and their use. However, we need to keep in mind that we can't loose focus on the goal, which is to write a model of the real the least number of bytes. I condensed even further this one: 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]]] Does not look good for Rebol. Not that I judge a language by its compatibility at all, but it is just plain fun to compare, we are mostly boys after all. So... The problem stated clearly is: Monty shows you three curtains. Behind one curtain is a prize, the others nothing. REBOL: Set up THREE variables in Rebol, 1 "different" than the other two. Pick a door at random. REBOL: Pick a variable at random. Once picked, one of the doors will be revealed to you, which is guaranteed to be empty. REBOL: Search through the variables until an empty one is found, remove it from the list. Or mark it in some manner. Offer chance to switch. REBOL: Always switch, and if percentage chance of receiving prize ("different") of the remaining two variables, print a statement, or even the simple number which is the percentage chance of receiving the prize. We have to include the spaces and the "rebol[]_" in our count. Just this header is 8, since Rebol requires spaces. So use 1 letter variable names. If you write something "tricky" then simply break it down in your email. This will both prove that it is a good model, and teach the rest of us more about the nature of writing good programs, and make yourself a god, all at the same time! If you think you have really modeled the problem correctly, and in the LEAST number of bytes, then append the statement to the Subject line "IN n bytes." Where n is the actual number you were able to achieve. Reichart... [Reichart--Prolific--com] Be useful.