MCPcopy
hub / github.com/azl397985856/leetcode / threeDoors

Function threeDoors

daily/answers/three-doors-problem.js:3–10  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1// true 代表换之后赢了
2// false 代表换了之后输了
3function threeDoors() {
4 const doors = [0, 0, 1];
5 const random = Math.random() * doors.length;
6 const pos = Math.floor(random);
7 if (doors[pos]) return false;
8 console.count(pos);
9 return true;
10}
11
12const times = 1000000;
13for(let i = 0; i < times; i++) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected