Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
|
|
@ -0,0 +1,47 @@
|
|||
10 REM Monty Hall problem
|
||||
20 LET N = 10000
|
||||
30 RANDOMIZE
|
||||
40 LET W = 0
|
||||
50 FOR G = 0 TO N
|
||||
60 LET S = 0
|
||||
70 GOSUB 230
|
||||
80 IF V = 0 THEN 100
|
||||
90 LET W = W+1
|
||||
100 NEXT G
|
||||
110 PRINT "NOT switching doors wins car in";
|
||||
120 PRINT W/N*100; "per cent of games."
|
||||
130 LET W = 0
|
||||
140 FOR G = 0 TO N
|
||||
150 LET S = 1
|
||||
160 GOSUB 230
|
||||
170 IF V = 0 THEN 190
|
||||
180 LET W = W+1
|
||||
190 NEXT G
|
||||
200 PRINT "But switching doors wins car in";
|
||||
210 PRINT W/N*100; "per cent of games."
|
||||
220 END
|
||||
230 REM ** Is game won?
|
||||
240 REM Play one game.
|
||||
250 REM Switching if and only if S <> 0.
|
||||
260 REM Randomly place car behind a door.
|
||||
270 LET C = INT(RND*3)
|
||||
280 REM Player randomly chooses a door.
|
||||
290 LET P0 = INT(RND*3)
|
||||
300 REM Monty opens door revealing a goat.
|
||||
310 LET M = INT(RND*3)
|
||||
320 IF M = C THEN 310
|
||||
330 IF M = P0 THEN 310
|
||||
340 IF S = 0 THEN 410
|
||||
350 REM Player switches to remaining door.
|
||||
360 LET P = INT(RND*3)
|
||||
370 IF P = P0 THEN 360
|
||||
380 IF P = M THEN 360
|
||||
390 GOTO 430
|
||||
400 REM Player sticks with original door.
|
||||
410 LET P = P0
|
||||
420 REM Victory?
|
||||
430 IF P <> C THEN 460
|
||||
440 LET V = 1
|
||||
450 RETURN
|
||||
460 LET V = 0
|
||||
470 RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue