If hits plus blows equal the number of digits, you have all the symbols. And ”0 hits, all blows” is an especially clear clue: every symbol is in the wrong place.

How many orders are left?

Say “0123” got 0 hits and 4 blows with 4 digits. The answer is some rearrangement of 0, 1, 2 and 3, and no symbol is in its original place. If you count them, there are these 9:

1032 1230 1302 2031 2301 2310 3012 3201 3210

There are 24 ways to arrange 4 symbols in all, but only 9 of them keep every symbol out of its original place. Here are the numbers for each length (we counted through all the answers to check).

DigitsAll arrangementsNone in its original place
3 digits62
4 digits249
5 digits12044
6 digits720265
7 digits50401854

With 3 digits, if “012” got 0 hits and 3 blows, the answer is one of only 2 rows: “120” or “201”.

Settling it from the 9 orders of 4 digits

To find the answer among the 9, the trick is to use a guess that splits the 9 well. For example, compare these two guesses.

  • 1032 (one of the 9): splits them into 1 solved, 4 with 2 hits and 2 blows, and 4 with 0 hits and 4 blows.
  • 1034 (a deliberate miss that adds a 4): splits them into 1 with 3 hits, 2 with 2 hits and 1 blow, 2 with 1 hit and 2 blows, and 4 with 0 hits and 3 blows.

For both, the most that can be left is 4 orders. But 1032 has a chance of being right, so it is better than 1034. In the same way, once few are left, choose a row from the candidates that splits the candidates well.

#10123HIT 0BLOW 4#21032HIT 0BLOW 4#33210HIT 0BLOW 4#42301HIT 4BLOW 0Answer2301

In this example, 1032 gave 0 hits and 4 blows, leaving 4 orders: 2301, 2310, 3201 and 3210. The next guess, 3210, also gave 0 hits and 4 blows, leaving only 2301, and guess 4 solved it. 3210 splits the 4 orders into 1 solved, 2 with 2 hits and 2 blows, and 1 with 0 hits and 4 blows.

Once the total matches, switch to thinking about places

Once hits plus blows equal the number of digits, you no longer need to look for symbols. From here on, think only about places.

  • A symbol with 0 hits cannot go in that place: For each guess, write down which symbol cannot go in which place, and the places that are left start to show.
  • Swap two and compare: If you swap just two symbols’ places, the hits may go up by 2, down by 2, or stay the same. That tells you about those two places.

When every symbol has 0 hits, you know “no symbol is in its original place,” so the number of orders drops a lot. All blows is a welcome clue: you have all the symbols, and you also have clues about the places.

Other tips are collected in Tips for Bulls and Cows.