What is Bulls and Cows?
Bulls and Cows plays Code Breaker with digits instead of coloured pegs. The codemaker writes a secret number of four different digits from 0 to 9, and 0 may stand first, so 0371 is a valid secret. The codebreaker answers with numbers of four different digits, and after each one learns how many bulls and how many cows it scored.
A bull is a right digit in the right place, like a black peg in the colour game. A cow is a digit that is in the secret number but stands somewhere else, like a white peg. With secret 4271 and guess 1234, the 2 is a bull, and the 1 and the 4 are cows: one bull, two cows. Four bulls crack the code. Because no digit repeats, every bull and cow points at exactly one digit of the secret, but you still have to work out which.
There are 5,040 possible secrets, almost four times as many as in the standard game, and ten digits to rule in or out instead of six colours, so a good first few guesses matter more.
Rule changes
| Rule | Standard Code Breaker | Bulls and Cows |
|---|---|---|
| Symbols | Standard Code BreakerSix colours of pegs. | Bulls and CowsThe ten digits 0 to 9. A secret or a guess may start with 0. |
| Repeated symbols | Standard Code BreakerA colour may appear more than once, in the code and in every guess. | Bulls and CowsAll digits differ, in the secret number and in every guess. |
| Feedback | Standard Code BreakerA black peg for each right colour in the right place, a white peg for each right colour in the wrong place. | Bulls and CowsA bull for each right digit in the right place, a cow for each right digit in the wrong place, counted the same way as the pegs. |
| Code length | Standard Code Breaker4 pegs, 1,296 possible codes. | Bulls and Cows4 digits, 5,040 possible secrets. The code length option also offers 3, 5 or 6 digits. |
| Other options | Standard Code Breaker10 guesses, six colours, repeated colours allowed and no blanks. | Bulls and CowsThe guess limit of 6, 8, 10 or 12 still applies. Colour count, no duplicates and blanks belong to the colour game and are not offered. |
History
Bulls and Cows, also called Cows and Bulls or Pigs and Bulls, is a pencil-and-paper game that is older than the board game with coloured pegs and may go back a century or more. The peg game, invented by Mordecai Meirowitz in 1970, is based on it.
It was also one of the early games written for computers. Frank King wrote a version on the Titan computer at the Cambridge Computer Laboratory some time before the summer of 1970, and a version called MOO was ported to Multics at MIT in 1972 and rewritten for early Unix at Bell Labs. A BASIC version of MOO was shared through the program library of DECUS, the users' society of the computer maker DEC, by 1971.
With four digits, every secret can be found within seven guesses, and the best possible play needs about 5.21 guesses on average.