Bulls and Cows

Play full screen
Rate this game

No ratings yet. Be the first.

How to play

Bulls and Cows is a pencil-and-paper code-breaking game with numbers. In Turkey it is played as Sayı Bulmaca, which is where the plus and minus clues on this board come from.

The secret number has 3, 4 or 5 digits (pick with Digits). Every digit is different and the first digit is never 0. Your guesses follow the same rules, so the keypad greys out a digit you’ve already used in this entry, greys out 0 as a first digit, and won’t let you send the same number twice.

The clue after each guess is two counts:

  • +n: n of your digits are in the secret number and in the same position.
  • −n: n of your digits are in the secret but in a different position.
  • 0: none of your digits appear anywhere.

Say the secret is 4096 and you guess 4567. The 4 sits in the right spot, the 6 is in the number but in the wrong spot, and 5 and 7 aren’t there at all, so the clue reads +1 −1. Notice that the clue never tells you which digits earned it; that’s the puzzle.

Type with the on-screen keypad or your keyboard, fix mistakes with Delete, and press Guess.

Solo and vs Computer

Solo is pure code-breaking. The computer hides a number and you try to find it in as few guesses as possible; the final screen tells you how many it took.

vs Computer is a race, and the screen splits into “Your guesses” and “Computer’s guesses”. First you set a secret number of your own for the computer to crack (or press Random number). Then you take turns, and you always guess first. If you crack its number, the computer still gets one more guess so you have both had the same number of tries: if it finds yours with that last guess, the game is a draw. If the computer cracks your number first, it wins. The computer’s number is revealed when the game ends.

Computer level only matters in this mode:

  • Easy looks only at its last two clues until it has made ten guesses, so it often repeats ideas you can see are already ruled out.
  • Medium always guesses a number that fits every clue it has received.
  • Hard does the same, and once the possibilities shrink to a few hundred it picks the guess whose worst-case clue leaves the fewest numbers standing.

How big the search is

Because digits can’t repeat and the lead digit can’t be 0, the number of possible secrets is easy to count: 648 with three digits (9 × 9 × 8), 4,536 with four (× 7), and 27,216 with five (× 6). Every clue cuts that pile down.

Strategy

Spend the first guesses on coverage. With four digits, guesses like 1234 and 5678 between them test eight of the ten digits. Add up their clue totals (plus and minus together) and you know how many of the secret’s digits are 9 or 0 without guessing either.

Treat a 0 clue as a gift. Every digit in that guess is out, wherever it was placed. Mark them all at once.

Use the digit notes. The row of digits above the keypad is your scratch pad. Tap a digit once to cross it out (not in the number), a second time to mark it green (definitely in), and a third time to clear it. Notes are kept with your saved game.

Change one thing at a time. Once you know which digits are in, swap just two positions between guesses. If + goes up by two, both moved home; if it drops, they were right before.

Only guess numbers that could still be the answer. A guess that contradicts an earlier clue can never win, and in a race it wastes a turn the computer won’t waste.

Against Hard, open strong. Once it has narrowed things down the hard computer plays close to optimally, and cracking the code one turn after it is a loss, not a draw.

If you like this kind of deduction with colours instead of digits, try Color Code, which uses black and white pins for the same idea.

If you enjoy Bulls and Cows, try Color Code or Crate Push next.

Frequently asked questions

What do the + and − clues mean?

Plus counts digits that are correct and in the correct position. Minus counts digits that are in the number but somewhere else. A 0 means none of the guessed digits are in the secret.

Why are some digit keys switched off?

The secret can't repeat a digit or start with 0, and neither can your guesses. A digit you've already typed in the current entry is disabled, and 0 is disabled for the first position.

Who wins if we both crack the number?

You always guess first. If you crack the computer's number, it gets one final guess to match your number of tries. If it also succeeds, the game is a draw.

How good is the computer on each level?

Easy reasons only from its last two clues for its first ten guesses. Medium always makes a guess that fits all its clues. Hard additionally chooses the guess that leaves the fewest possibilities in the worst case once the candidates are down to a few hundred.

How many possible secret numbers are there?

648 with three digits, 4,536 with four and 27,216 with five, since digits never repeat and the first digit is never 0.

Does the game save my progress?

Yes. The game is saved after every guess, together with your digit notes.

Add Bulls and Cows to your website

Free, no sign-up. Paste the code into any page. The credit line under the game is optional, but we appreciate it. On WordPress, use our plugin and the shortcode.

Embedding rules and options