Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Monty-Hall-problem/BBC-BASIC/monty-hall-problem.basic
Normal file
21
Task/Monty-Hall-problem/BBC-BASIC/monty-hall-problem.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
total% = 10000
|
||||
FOR trial% = 1 TO total%
|
||||
prize_door% = RND(3) : REM. The prize is behind this door
|
||||
guess_door% = RND(3) : REM. The contestant guesses this door
|
||||
IF prize_door% = guess_door% THEN
|
||||
REM. The contestant guessed right, reveal either of the others
|
||||
reveal_door% = RND(2)
|
||||
IF prize_door% = 1 reveal_door% += 1
|
||||
IF prize_door% = 2 AND reveal_door% = 2 reveal_door% = 3
|
||||
ELSE
|
||||
REM. The contestant guessed wrong, so reveal the non-prize door
|
||||
reveal_door% = prize_door% EOR guess_door%
|
||||
ENDIF
|
||||
stick_door% = guess_door% : REM. The sticker doesn't change his mind
|
||||
swap_door% = guess_door% EOR reveal_door% : REM. but the swapper does
|
||||
IF stick_door% = prize_door% sticker% += 1
|
||||
IF swap_door% = prize_door% swapper% += 1
|
||||
NEXT trial%
|
||||
PRINT "After a total of ";total%;" trials,"
|
||||
PRINT "The 'sticker' won ";sticker%;" times (";INT(sticker%/total%*100);"%)"
|
||||
PRINT "The 'swapper' won ";swapper%;" times (";INT(swapper%/total%*100);"%)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue