Puzzle: Wolves and sheep

Here’s a new integer sequence that does not appear to be in the OEIS yet:

k=       1  2  3  4  5  6  ...
      0
n=1   0  0
n=2   0  1  0
n=3   0  2  2  0
n=4   0  2  3  3  0
n=5   0  3  4  4  4  0
n=6   0  3  5  5  5  5  0
n=7   0  3  6  6  6  6  6  0
n=8   0  3  6  7  7  7  7  7  0
n=9   0  4  7  8  8  8  8  8  8  0
n=10  0  4  7  9  9  9  9  9  9  9  0
n=11  0  4  8 10 10 10 10 10 10 10 10  0
n=12  0  4  8 11 11 11 11 11 11 11 11 11  0
n=13  0  4  .  . 12 12 12 12 12 12 12 12 12  0
n=14  0  4  .  . 13 13 13 13 13 13 13 13 13 13  0
n=15  0  4  .  .  . 14 14 14 14 14 14 14 14 14 14  0
n=16  0  4  .  .  . 15 15 15 15 15 15 15 15 15 15 15  0
n=17  0  5  .  .  .  . 16 16 16 16 16 16 16 16 16 16 16  0
n=18  0  5  .  .  .  . 17 17 17 17 17 17 17 17 17 17 17 17  0
n=19  0  5  .  .  .  .  . 18 18 18 18 18 18 18 18 18 18 18 18  0
n=20  0  5  .  .  .  .  . 19 19 19 19 19 19 19 19 19 19 19 19 19  0

However, I admit that my OEIS-fu isn’t very good. I’ve seen that when there’s a triangular sequence like this, it’ll generally be entered into OEIS in row-major order, i.e. —.

However, in this particular sequence, the rightmost edge is uninteresting (it’s just ), and so conceivably the sequence might be entered into OEIS sans that edge: —. Or it might be entered including one or more of the surrounding zeroes. Or some other more radical serialization, such as —.

I wonder whether the OEIS’s search function automatically looks for such variations on a sequence being searched for, and how much work it would be to do so. (UPDATE: It does not automatically look for such variations.)


The sequence above is defined as the solution to the following puzzle for various values of . Paraphrasing Jyotish Robin on Puzzling StackExchange:

You have sheep. Unfortunately, you have been informed that exactly of these sheep are really wolves in disguise. You have at your disposal a blood test that can reliably detect wolf DNA: given a vial of blood from any number of subject animals, a single test will tell you whether all of the subjects were innocent sheep or (vice versa) whether at least one subject was a wolf.

The testing lab is in a distant city; therefore you must collect all your blood samples before you have learned any of the results. You cannot use the result of one test to inform your strategy for the other tests. Also, your testing strategy must have a 100% success rate at identifying all wolves; “99% probability of success” is not good enough for this puzzle.

How can you minimize the number of tests required?

The first really interesting case is . Suppose you have eight sheep, and you know that two of them are wolves. Certainly you could find the wolves in seven tests: you’d just test seven of your animals individually and then use the results to deduce the species of the eighth. But how can you find the two wolves in fewer than seven tests?

I have a brute-force solver on GitHub. It finds the answers up to pretty quickly; has some slowdown on ; and takes quite a while on . It can produce a solution for in about 5 seconds, and for in just under a minute.

Posted 2019-04-17