PROJECT EULER · #0352
Blood Tests
Each one of the
Because of the high cost, the vet-in-charge suggests that instead of performing
The sheep are split into
- If the result is negative, all the sheep in that group are deemed to be virus-free.
- If the result is positive,
additional tests will be performed (a separate test for each animal) to determine the affected individual(s).
Since the probability of infection for any specific animal is only
- Negative (and no more tests needed) with probability
. - Positive (
additional tests needed) with probability .
Thus, the expected number of tests for each group is
Consequently, all
Although the scheme we have just described seems to be very efficient, it can still be improved considerably (always assuming that the test is sufficiently sensitive and that there are no adverse effects caused by mixing different samples). E.g.:
- We may start by running a test on a mixture of all the
samples. It can be verified that in about of the cases this test will be negative, thus no more tests will be needed. Further testing will only be required for the remaining of the cases. - If we know that at least one animal in a group of
is infected and the first individual tests come out negative, there is no need to run a test on the fifth animal (we know that it must be infected). - We can try a different number of groups / different number of animals in each group, adjusting those numbers at each level so that the total expected number of tests will be minimised.
To simplify the very wide range of possibilities, there is one restriction we place when devising the most cost-efficient testing scheme: whenever we start with a mixed sample, all the sheep contributing to that sample must be fully screened (i.e. a verdict of infected / virus-free must be reached for all of them) before we start examining any other animals.
For the current example, it turns out that the most cost-efficient testing scheme (we'll call it the optimal strategy) requires an average of just
Using the optimal strategy, let
Thus, rounded to six decimal places,
Find
Give your answer rounded to six decimal places.
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.