## 四個機率問題

• 每一次有 $\frac{1}{N}$ 成功的機率，跑 $N$ 次後最少成功一次的機率。
• $N$ 個球隨機丟到 $N$ 個籃子後有空籃子的機率。
• $N$ 個數字在隨機排序後有數字不改變位置的機率。
• $N$ 種 coupon 平均隨機出現，要抽中一套 $N$ 種都有的 coupon 需要抽幾次的期望值。

## 用程式解數學邏輯問題...

Which answer in this list is the correct answer to this question?

• All of the below.
• None of the below.
• All of the above.
• One of the above.
• None of the above.
• None of the above.

accepted 的那個是推演的答案，但最高分的那個是寫程式窮舉 XDDD (不得不說大家都很愛這味...)

## 二戰時德國坦克製造速度的估算問題

Hacker News Daily 上看到「Googlebot’s Javascript random() function is deterministic」這則有趣的發現。作者發現 Googlebot 的 Math.random() 並不隨機，甚至是固定的：

The first time Googlebot calls Math.random() the result will always be 0.14881141134537756, the second call will always be 0.19426893815398216. The script I linked to above simply uses this fact but obfuscates it a little and ‘seed’ it with something that doesn’t look too arbitrary.

## V8 Engine 的 Math.random() 在新版被重寫了...

This has been pointed out to us, and having understood the problem and after some research, we decided to reimplement Math.random based on an algorithm called xorshift128+. It uses 128 bits of internal state, has a period length of 2128 - 1, and passes all tests from the TestU01 suite.

The new implementation landed in V8 4.9.41.0 within a few days of us becoming aware of the issue. It will become available with Chrome 49. Both Firefox and Safari switched to xorshift128+ as well.

Make no mistake however: even though xorshift128+ is a huge improvement over MWC1616, it still is not cryptographically secure.

## V8 的 Math.random() 亂度不足的問題

If you’re only using the most significant 16 bits it has a very short effective cycle length (less than 2³⁰).