Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
19
Task/Monty-Hall-problem/QuickBASIC/monty-hall-problem.basic
Normal file
19
Task/Monty-Hall-problem/QuickBASIC/monty-hall-problem.basic
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
RANDOMIZE TIMER
|
||||
DIM doors(3) '0 is a goat, 1 is a car
|
||||
CLS
|
||||
switchWins = 0
|
||||
stayWins = 0
|
||||
FOR plays = 0 TO 32767
|
||||
winner = INT(RND * 3) + 1
|
||||
doors(winner) = 1'put a winner in a random door
|
||||
choice = INT(RND * 3) + 1'pick a door, any door
|
||||
DO
|
||||
shown = INT(RND * 3) + 1
|
||||
'don't show the winner or the choice
|
||||
LOOP WHILE doors(shown) = 1 OR shown = choice
|
||||
stayWins = stayWins + doors(choice) 'if you won by staying, count it
|
||||
switchWins = switchWins + doors(3 - choice - shown) 'could have switched to win
|
||||
doors(winner) = 0 'clear the doors for the next test
|
||||
NEXT plays
|
||||
PRINT "Switching wins"; switchWins; "times."
|
||||
PRINT "Staying wins"; stayWins; "times."
|
||||
Loading…
Add table
Add a link
Reference in a new issue