A simple Bulls and Cows game implemented in Python. The game generates a random 4-digit number with unique digits, and the player has to guess it. For each guess, the game provides feedback in the form of bulls and cows.
- Bull → correct digit in the correct position
- Cow → correct digit in the wrong position
Generates a random 4-digit number with unique digits (no leading zero).
Validates user input:
- Must be exactly 4 digits
- No duplicates allowed
- Cannot start with 0
- Only digits are accepted
Provides feedback after each guess in the form of bulls and cows.
Tracks number of guesses and time taken for each game.
Stores a game statistic showing the number of guesses for each round.
Allows the player to play multiple rounds.
- Run the game using Python 3:
python main.py - The game will generate a random 4-digit number.
- Enter your guess. The program will check your input and provide feedback:
Enter a number: 6978
>>> 6978
4 bulls, 0 cows
-----------------------------------------------
Correct, you've guessed the right number in 5 guesses!
It took you 44 seconds.
-----------------------------------------------
That's amazing!
Your game statistic: [5]
- Repeat guessing until you find the correct number.
- After winning, the game will show your total guesses and time taken.
- You can choose to play again or exit.
- The secret number is different each game.
- Input validation ensures fair play and avoids invalid guesses.
- Statistics are stored in a simple list and updated after each round.
- The game is terminal-based and works on any system with Python 3 installed.