forked from azl397985856/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
luzhipeng
committed
Jun 14, 2019
1 parent
2abdabc
commit a3d96e7
Showing
7 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// true 代表换之后赢了 | ||
// false 代表换了之后输了 | ||
function threeDoors() { | ||
const doors = [0, 0, 1]; | ||
const random = Math.random() * doors.length; | ||
const pos = Math.floor(random); | ||
if (doors[pos]) return false; | ||
console.count(pos); | ||
return true; | ||
} | ||
|
||
const times = 1000000; | ||
for(let i = 0; i < times; i++) { | ||
const win = threeDoors(); | ||
console.count(win); | ||
} |