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: sunandadh:aol at: 18-Dec-2001 6:21

Hi Riechart,
> But the goal is to not keep making the example shown with the C, MatLab, and > Pearl smaller, but to make a more verbose accurate portrayal of the
> puzzle in Rebol. > > I'm then going to go see if they can do the same in Pearl, or language of > choice.
Okay, I'm game. Here's a version of the Monty Simulator that plays the game 100 times, and prints the result for each play, and a final total. Our competitor swaps each time. To compare like with like, other programs shou;d exactly replicate the format of the printed lines. The program as presented is about 350 bytes I reserve the right to reduce it to under 250 bytes for a "final version". I am also fairly confident that I can do a full GUI implementation in under 1K Rebol [] N: 100 Loop N [ D: random/secure [Red Green Blue] C: pick D random 3 prin["I pick"D/1] M: next D if find M C[alter M C] prin[". M shows"M/1] either 1 = length? M [prin [". I swap to"C]] [prin [". I swap to"M/2]] prin[". Car was behind" C] either D/1 = C [print ". I lose."N: N - 1] [Print ". I win."] ] print ["Wins:" N] Notes on variables: D - for Doors array C - colour of door that hides the car M - for Monty's two doors N for loop count and wins (using Ryan's ingenious two-for-the-price of one trick) Print line format is: I pick [col]. M shows [col]. I swap to [col]. Car was behind [col]. I [win/lose]. where [col] = colour name. last line: wins: nn Sunanda.