The program is a game of Cows and Bulls. The aim of the game is to guess a 4 digit number that has been randomly generated. To help guessing the player will get hints to say what
numbers are correct and in the right place (bulls) or correct but in the wrong place (cows)..
The program will be created using python programming language and using the IDLE IDE.
The first part of the program needs to generate a number and make sure the 4 numbers are not repeated. The python random module should be imported into the program,
in order to generate a random number. The generated number will be the format of a python list of 4 digits, so that the values can be looped through.
The python function randrange() can be used to generate a single number between 0 and 9, as required in the scenario.
A loop is needed to do this 4 times and check that the number is not duplicated, by comparing each new number to those generated in previous iterations of the loop. See Flow Chart 2.
The program needs to allow the player to enter a guess and continue doing this until the generated number is guessed or they type exit. See Flow Chart 1.
The user entered number needs to be validated to ensure it is a four digit number without duplicates. A loop is needed to check each digit in the number and ensure it is not used twice or more.
See Flow Chart 3.
The user entered number needs to be compared to the random generated number. To do this each digit in the user number is compared to the digit in the same position in the random number.
If they are equal then 1 will be added to the bulls counter. If the user digit is not in the same position but is in the random number anyway then 1 is added to the cows counter. Flow Chart 4.