Bulls and Cows numerical version class.
Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking mind or paper and pencil game for two or more players, predating the similar commercially marketed board game Mastermind. The numerical version of the game is usually played with 4 digits, but can also be played with 3 or any other number of digits.
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 wins the game. As the “first one to try” has a logical advantage, on every game the “first” player changes. In some places, the winner of the previous game will play “second”. Sometimes, if the “first” player finds the number, the “second” has one more move to make and if he also succeeds, the result is even.
The game may also be played by two teams of 2–3 players. The players of every team discuss before making their move, much like in chess.
It is proven that any number could be solved using up to seven turns. Minimal average game length is 26274/5040=5.2131 turns
Below Class can be used to create your own game.