Skip to content
bobob

Puzzle2-5 min

Number Baseball

Strikes and balls are the only clues to the hidden number

Loading the game...

How to play

  1. 1Choose 3 digits or 4. The secret is built from different digits out of 0 to 9 and may well start with 0.
  2. 2Enter a guess of different digits and press Pitch. The keyboard works too: digits to type, Backspace to erase, Enter to pitch.
  3. 3Read the reply. A digit right in the right place is S, a digit in the number but in the wrong place is B, and nothing in common is OUT. The board also shows how many numbers are still possible.
  4. 4Use the Notes tab beside the log to mark a digit not it or sure for each position, so you are not holding it all in your head. Long-press or right-click a digit to cross it off every position at once.
  5. 5Stuck? Turn on the coach, or press H. Fill the input and it tells you how many candidates that pitch would leave on average and at worst; leave it empty and it suggests a pitch. Enter something that contradicts an earlier reply and it names the try it disagrees with.
  6. 6Under the coach, Fill in what is certain writes only the cells that every remaining candidate agrees on. It never writes a guess.
  7. 7Get every digit in its place inside ten tries and you win. The Record button shows games finished, how many you solved, your average tries and your day streak.

Controls

Number keys / on-screen pad
Enter a digit
Backspace / Delete
Erase the last digit
Enter / Pitch
Submit the guess
H
Turn the coach on and off
Right click / long press a digit
Mark it as not in the number
Tap a notes cell
Cycle unknown, not it, sure for that position

Tips

  • Open with 012, then 345, keeping the digits from overlapping. At three digits one pitch cuts the field from 720 to about 180, and two usually bring it down to a few dozen.
  • An OUT is not the good news it feels like. Counting what each reply to 012 leaves behind, 0S1B leaves 252 and OUT leaves 210 - the two biggest - while 1S0B leaves 126, 1S1B leaves 42 and 2S0B only 21. Losing three digits at once looks tidy, but you learned nothing at all about position. The digits you pitched are at least crossed off every position in the notes automatically.
  • Change one digit at a time and watch whether S goes up or down - that tells you which position that digit belongs to. Swapping two digits between positions works the same way and settles their relationship in one pitch.
  • Once the field is down to five or six, do not pitch at random. Pick the number that differs from the others in as many positions as possible, because that is what splits them most. It is the same rule the coach uses.
  • Pitching a number that cannot be the answer is a legitimate tactic. Choosing only from the surviving candidates costs 5.25 tries on average at three digits, while allowing any pitch at all brings that to 5.05 with a worst case of 6. A pitch with no chance of winning can still carry more information.
  • When the possible-numbers figure on the board reaches 1, the answer is pinned down, and the coach simply tells you what it is.

What is Number Baseball?

You pitch 123 and back comes 1S 1B. One digit is right and in the right place, one is in the number but somewhere else. Stack up clues like that and the hidden number falls out.

It is the pencil-and-paper game played in classrooms everywhere, known in English as bulls and cows. The secret is made of digits that do not repeat, a digit right in the right place is a strike, a digit in the number but misplaced is a ball, and nothing at all is an out.

One pitch tells you little, but overlapping the clues shrinks the field remarkably fast. Counting numbers that may begin with 0, there are 720 three-digit secrets and 5,040 four-digit ones. Pitch 012 at three digits and the reply splits nine ways, leaving 180 candidates on average and 252 in the worst case. Pitch 0123 at four digits and the reply splits fourteen ways, leaving 931 on average and 1,440 at worst. More than three in four of the field goes in a single pitch.

The figures here are not estimates. Playing every one of the 720 three-digit secrets through, picking at random among whatever is still possible takes 5.25 tries on average and 9 at worst; all 5,040 four-digit secrets take 5.47 on average and 9 at worst. Picking the pitch that splits the field most evenly brings three digits to 5.15 on average and 8 at worst, and four digits to 5.25 and 7. Allowing pitches that cannot be the answer brings the three-digit worst case down to 6.

Frequently asked questions

How many tries does it take to solve?

It was counted rather than guessed. Picking at random from whatever is still possible, all 720 three-digit secrets took 5.25 tries on average with a worst case of 9, and all 5,040 four-digit secrets took 5.47 with a worst case of 9. Choosing the pitch that splits the field most evenly gives 5.15 and 8 at three digits, 5.25 and 7 at four.

Are ten tries enough?

Comfortably. In those exhaustive runs not one of the 720 three-digit games or the 5,040 four-digit games went past ten, and the unluckiest took nine. So as long as you read the replies and never pitch something that contradicts them, you will not run out. If ten was not enough, a pitch probably disagreed with an earlier reply, and the coach points that out.

What is the best opening pitch?

Any of them. All 720 possible three-digit openings were evaluated and every single one leaves 180.09 candidates on average with a worst case of 252. With no information yet, they are the same pitch under different digit names, so no mathematical difference is possible. The choices start to matter from the second pitch, so keep the digits from overlapping and sweep through all ten quickly.

What does the coach actually compute?

It enumerates the real field. All 720 three-digit or 5,040 four-digit numbers are checked one by one against every strike-and-ball reply so far, and only the survivors are kept. Then it tries each candidate as a pitch, counts how many would be left under each possible reply, and recommends the one with the smallest average. With a wide field it works from an even sample and says so. Everything runs inside this browser and the answer is never revealed.

Can I pitch a number that contradicts an earlier reply?

You can. Nothing blocks it; the coach just says which try it disagrees with. A number that cannot win sometimes splits the field better, so throwing one deliberately is a real tactic. If it was a slip, though, you have spent a try for nothing, so read the coach and choose again.

What does filling in the notes automatically write?

Only the cells on which every remaining candidate agrees. If no candidate puts that digit in that position it writes not it, and if every candidate does it writes sure. Cells the candidates disagree about are left alone, so everything written that way is proved by the replies and no guess is ever included.

May the secret start with 0, and can a digit repeat?

A secret like 012 is possible, and you can lead a guess with 0 too. Repeating a digit is not allowed in the secret or in a guess, and pitching a number you have already pitched is refused as well.

Where are my records kept?

The fewest tries at each digit length is stored in this browser only. The Record button also shows games finished, the share you solved, the average tries of the solved ones, your day streak and the fewest tries at three and four digits. A game you did not crack inside ten tries does not go into the fewest-tries record.

Similar games

All Puzzle games