# Bulls and Cows

Let’s play it.

The game involves guessing a 4-digit secret number through a series of strategic guesses. If players manage to guess a certain digit, and that digit is positioned in the right place the game master will inform them on their correct guesses by means of the denomination “Bull.” If players guess the digit, but the position is not the correct one, the game master will inform them on that through the term “Cow.” The first player to find the secret number will be declared the winner and will become the game master of the next round of the game.

I played this game a lot when I was in school and there are different versions. We will play the standard version here, where the 4-digit number can start with 0 but the digits must be all different. Here is the description of the game on Wikipedia:

On a sheet of paper, the players each write a 4-digit secret number. The digits must be all different. Then, in turn, the players try to guess their opponent’s number who gives the number of matches. If the matching digits are in their right positions, they are “bulls”, if in different positions, they are “cows”. Example:

Secret number: 4271
Opponent’s try: 1234
Answer: 1 bull and 2 cows. (The bull is “2”, the cows are “4” and “1”.)

The first one to reveal the other’s secret number in the least number of guesses wins the game.

The game is traditionally played by two players, but here the game master will pick the secret number and give the players who post their guesses the number and quality of their matches.

I can think of two problems:

1. The game master can change the secret number, especially in the first stage of the game. I don’t really know how to handle this situation in a practical way. In real life, players will write down the number on a piece of paper and put it aside. Thus, the number can be verified at the end of the game.

2. The game master can give the wrong information on the matches. I’ve come across with the situation in real life quite frequently. My friends and I solved this problem by declaring the game null and recording it as a loss for the person who gave the wrong information. I think the same rule should be followed here: If the game master (accidentally or not) gives the wrong information on Bulls and Cows, then the game master will lose the game and the player who has received the wrong information will become the winner and the game master of the new round of the game.

Here’s the first secret number:

It is a number I have extracted from a “reliable source” that I will reveal when the round ends.

My guess is 4375.

Guess # 1: 4375 - 1 C (one Cow)

My guess: 1413

In this version of the game, both the secret number and the guesses must include a digit only once.

Oh, ok.
Guess: 1423

Thank you.

Guess # 1 Monty: 4375 – 1C (one Cow)
Guess # 2 Beckdawreck: 1423 – 1B (one Bull)

My next guess is: 6478.

Is it okay for the guesser to give the reasoning for second and subsequent guesses?

Yes, I think comments and discussions should be allowed.
It is not an official tournament or something.

Guess # 1 Monty: 4375 – 1C (one Cow)
Guess # 2 Beckdawreck: 1423 – 1B (one Bull)
Guess # 3 Monty: 6478 – 1B (one Bull)

Cool! Well my first guess included the number 4 which got me a cow. Beckdawrek also guessed a 4 but she got a bull and her 4 was in the second position. We both guessed a 3 but in different positions. That tells me, unless I’m way off on the reasoning, that there is no 3 in the secret number. So, I figured I’d go with 6478 for my second guess.

That’s why the game is a really interesting one.

So, since a number cannot be repeated, we can either figure that there is a 4 in the right place, and no 1 2 3 5 6 7 8, or we can discard that theory, because that only leaves 0 and 9, which isn’t enough for a four digit number. Discard the 4.

We can figure 7 is out because in guess 1 it would be in the wrong place, but in guess 3 it was in the right place, while being in the same position in both cases.

Guess # 1 Monty: 4375 – 1C (one Cow)
Guess # 2 Beckdawreck: 1423 – 1B (one Bull)
Guess # 3 Monty: 6478 – 1B (one Bull)
Guess # 4 Prof.Pepperwinkle: 6093 – 1B (one Bull)

6528?

You’re getting closer.

Guess # 1 Monty: 4375 – 1C (one Cow)
Guess # 2 Beckdawreck: 1423 – 1B (one Bull)
Guess # 3 Monty: 6478 – 1B (one Bull)
Guess # 4 Prof.Pepperwinkle: 6093 – 1B (one Bull)
Guess # 5 Prof.Pepperwinkle: 6528 – 2B & 1C (two Bulls and one Cow)

I’ve learned how to create a table:

 Number Player Guess Matches guess # 1 Monty 4375 1C (one Cow) guess # 2 Beckdawreck 1423 1B (one Bull) guess # 3 Monty 6478 1B (one Bull) guess # 4 Prof.Pepperwinkle 6093 1B (one Bull) guess # 5 Prof.Pepperwinkle 6528 2B&1C (two Bulls and one Cow)

I must have wasted the better part of an hour on an extremely laborious series of eliminations. If this guess isn’t right, I’m going to have to hit something.

My guess is 5028.

4C - Four Bulls!

I should have saved the table before posting it.
Luckily, I don’t have to write it again.

This is where I got the secret number:
3.1415926535897932384626433832795028

@bibliophage, congratulations! You win this round of the game.

Thank goodness. According to my calculations, that was the only remaining possibility, but I was afraid I might have made a mistake somewhere.

I have a four-digit number in mind. You may begin guessing.

My guess is 1234.