Skip to content

Iv3ta10/BullsCowsPythonGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Bulls and Cows Game

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

Features

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.

How to Play

  1. Run the game using Python 3:
    python main.py
  2. The game will generate a random 4-digit number.
  3. 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]
  1. Repeat guessing until you find the correct number.
  2. After winning, the game will show your total guesses and time taken.
  3. You can choose to play again or exit.

Notes

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages