Implement a CLI number guessing game with bulls and cows.
Unlock detailed company stats for this questionUpgrade
Build a CLI number guessing game (bulls and cows). The player must guess a 4-digit number with no repeated digits and has 7 attempts. Every guess must be a valid 4-digit number. Each guess results in a win (correct guess), a loss (7th attempt wrong) or a tip of X bulls and Y cows, where X is the number of correct digits in the correct positions and Y is the number of correct digits in wrong positions. Each new game gets a random number.
Examples, if the number is 1234:
- 1290 is 2 bulls and 0 cows
- 1234 wins
- 1562 is 1 bull and 1 cow
Validity: 0123 is invalid (cannot start with 0), 1023 is valid, 1123 is invalid (repeated digits).
Bonus: print "Gutter ball!!!" on 0 bulls and 0 cows, and never repeat the same number across games.
Community answers
No answers contributed by the community yet.
Related questions
Implement a Connect 4 game with working code.Implement a token ring with RingManager and RingElement classes.Related courses

Course

Course
Course
