i lands heads up with probability chances[i] (and tails with probability 1 - chances[i]). Tosses are independent.
The magician tosses each coin exactly once. Find the probability that exactly want coins land heads up.
An answer within 10⁻⁵ of the exact value is accepted.chances=[0.5, 0.5], want=1 → 0.5
Exactly one heads happens in two of the four equally likely outcomes, H-T and T-H, so 0.5.
chances=[0.25, 1.0, 0.0], want=1 → 0.75
The second coin always lands heads and the third never does, so the first one must land tails: 1 − 0.25 = 0.75.
chances=[0.5, 0.5, 0.5], want=3 → 0.125
chances=[0.5, 0.5], want=1
0.5
Run checks the first 3 tests in your browser. Submit checks all 85 tests on the server, hidden ones included.