Skip to content

Commit a3d96e7

Browse files
author
luzhipeng
committed
feat: 整理daily参考答案到backlog
1 parent 2abdabc commit a3d96e7

7 files changed

+16
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: backlog/daily/threeDoors.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// true 代表换之后赢了
2+
// false 代表换了之后输了
3+
function 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+
12+
const times = 1000000;
13+
for(let i = 0; i < times; i++) {
14+
const win = threeDoors();
15+
console.count(win);
16+
}

0 commit comments

Comments
 (0)