Question: Bulls and Cows Game in PYTHON We will use numbers as the secret. The number of digits will be a parameter in your program. You

Bulls and Cows Game in PYTHON

We will use numbers as the secret.

The number of digits will be a parameter in your program.

You may want to read up a bit on object oriented programming. We want to use object oriented design in the program.

The assignment is to write a program that will play the game with a human opponent and with a computer algorithm as the opponent.

*NOTE* cow - a digit that belongs to the secret number, but is in the wrong position, bull - a digit that belongs to the secret number and is in the correct position

EXAMPLE: the secret number is 1234. The number (guess) 5678 would result in 0 cows and 0 bulls. The guess 1567 would result in 0 cows and 1 bull (1 is in the secret number and in the correct position). The guess 1562 would result in 1 cow (the digit 2 is in the secret number but in the wrong position) and 1 bull (the digit 1). Similarly, the guess 1324 would result in 2 cows (3,2) and 2 bulls (1,4). Thus, you win the game when you guess all 4 digits correctly in the right position ( 0 cows, 4 bulls).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!