During one test a service dog smells a pile of coins and barks if there is a fake coin in it. If a dog is sick, whether it barks or not does not depend on the presence of fake coin, it happens randomly. Suppose and that we have coins, exactly one of which is fake. Assume that we have an excess number of service dogs, one of them is sick but we do not know which one. Device a strategy to find the fake coin using at most tests.
, 2021
Solution
Number the coins by -digit binary numbers from to . Let be the set of coins which have in -th position of the binary number. The first tests we perform with the help of different dogs. In the -th test we determine whether the set contains the fake coin. Without loss of generality we may assume that the dogs determined that all the digits in the number of the fake coin are 's. Due to the possible presence of the sick dog in these tests, it means in fact that the binary number of the fake coin contains at most one .
In the next test we let a new dog determine whether the coin is genuine. If the new dog barks then the coin is really fake, for otherwise two dogs had given us a false answer. If the new dog does not bark we find a dog we have not used before to test the suspected coin.
(i) If the last two dogs disagree one of them must be sick and hence the first dogs must be healthy. In this case the coin is the fake one.
(ii) If the last two dogs agree (by not barking) it follows that both of them are healthy. The reason is that if one of the last two dogs was sick and did not bark, it would mean that the first dogs were healthy, implying that the coin is fake, but then the other of the last two dogs is healthy and did not bark at the fake coin, a contradiction. Therefore one of the first dogs gave a wrong verdict. In this case we have possible candidates for the fake coin. We can find the fake coin using the last dog and tests using binary search.
It follows that no more than tests are needed.