Site logo

Bulls and cows, an online logical game with numbers

A number with how many digits?
| | | |

Your try:

Author: Petko Yotov 2002 - 2022


This is a very popular children's game in Bulgaria, somehow similar and probably an ancestor to the famous Mastermind -- guessing your oponent's number. Usually it is played with a sheet of paper and a pen against another kid and the first kid to find the other's secret number, wins. This here is an online version, you only guess the number chosen by the computer.

The goal of the game is to uncover the oponent's secret number with a minimal number of questions (try with less than ten). The computer indicates the number of matches in your proposition.



  secret: 2567
your try: 6578 : 1 bull and 2 cows

First select how many digits should have the secret number. The official game is played with 4-digit-numbers. More means more difficult game. Press the button "New game". The computer picks a random number. Type your proposition in the small text field and press Enter or "OK".

If you find the game difficult, press the button "Hint" and you will see the first digit of the secret number, then the second etc.


I am not very good at Bulls-and-cows strategy, but here is a sample analysed game. (Actually, the program will output the answers in reverse order.)

 [9:36:18] I am thinking about a number with 4 digits 3:-O
 1:  1234  : 1 b. 1 c. -> I always start this way.
 2:  2134  : 0 b. 2 c. -> One bull is either 1 or 2, only they changed
 3:  3214  : 0 b. 2 c. -> Try with 2 (back at it's place):
                          nope, then the bull is 1
     1***              -> I write this, for reminder
 4:  1324  : 2 b. 0 c. -> Next bull is either 3 or 2
 5:  1423  : 2 b. 0 c. -> Switch 3 and 4, no change, so the bulls are 1 and 2.
     1*2*              -> reminder

 6:  5678  : 0 b. 2 c. -> 4 new digits, if no match, then 0 and 9 are.
                          Both missing are here.
 7:  5867  : 2 b. 0 c. -> Shuffling and bingo: found both of the missing bulls,
                          they are 8 and 7, on the empty places!
 8:  1827  : the answer  3:-O  O-:C

Waiting for your comments/feedback.