len(beads) colors: exactly beads[i] beads of color i, an even total of 2m. The beads are shuffled and split at random into two bags of m beads each; every choice of m beads for the first bag is equally likely (beads of the same color are still distinct objects).
Return the probability that the first bag holds as many distinct colors as the second. Answers within 10⁻⁵ of the true value are accepted.beads=[2, 2] → 1.0
Two red and two blue beads. Of the 6 equally likely ways to choose two beads for the first bag, 4 give one of each color, so both bags have 2 colors; the other 2 give a single color in each bag, which is also equal. The answer is 1.0.
beads=[3, 1] → 0.0
There is only one blue bead, and whichever bag gets it ends up with 2 colors while the other has only red. The answer is 0.0.
beads=[1, 1, 2] → 0.6666666666666666
beads=[2, 2]
1.0
Run checks the first 3 tests in your browser. Submit checks all 79 tests on the server, hidden ones included.