## Problem 66

### Description


This problem was asked by Square.

Assume you have access to a function toss_biased() which returns 0 or 1 with a probability that's not 50-50 (but also not 0-100 or 100-0). You do not know the bias of the coin.

Write a function to simulate an unbiased coin toss.

### Solutions

這題目的重點，是怎麽用 `toss_biased()` 組合出機率相同的兩個事件。

假設 `toss_biased()` 出現 0 的機率是 a，出現 1 的機率是 1-a，那麼我們連續呼叫兩次的話，機率如下：

a. 連續兩次出現 0 的機率是 a^2
b. 第一次出現 0，第二次出現 1 的機率是 a(1-a)
c. 第一次出現 1，第二次出現 0 的機率是 a(1-a)
d. 連續兩次出現 1 的機率是 (1-a)^2

我們只要把 b. 視為「拋出 0」，c. 視為拋出 1，其他情境重跑即可。

[參考解法](./kotlin/066.md)
