Beta

Searching for Bulls

Description:

This version of Bulls & Cows is a variation of the later commercialised 'Mastermind' game, where one player has a secret code and the other attempts to guess it, with responses given relating to correctness of the guess.

In this kata, you will be provided with a list of code guesses and the resulting "responses", with your task being to return either the only valid code, or if more than one possiblity remains return a None value.

The 'code' is a 4 digit long sequence of the numbers 1-6 (given as a string). Unlike the orginal version, numbers are allowed to repeat. A guess is first coded with 'Bulls' for correct numbers in correct places, and 'Cows' for any remaining correct numbers that sit in incorrect places. As a response example, 1 Bull 2 Cows is shown as '1B2C'.

Example:

The secret code is: 3454

The guess is: 3524

The response would have been '2B1C' in this case as a 3 & 4 are in the correct position (Bulls), while the 5 is a correct guess but in the wrong location (a Cow). The 2 is ignored as it is neither a Bull nor a Cow.

The list of guesses is of varying lengths.

See the tests for the format of inputs, but it will be [(str(guess), str(response))] with a string answer (or None) required.

Puzzles
Games
Permutations

Similar Kata:

More By Author:

Check out these other kata created by fatherof4

Stats:

CreatedApr 14, 2020
PublishedApr 15, 2020
Warriors Trained215
Total Skips129
Total Code Submissions295
Total Times Completed25
Python Completions25
Total Stars5
% of votes with a positive feedback rating69% of 13
Total "Very Satisfied" Votes7
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes2
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • fatherof4 Avatar
Ad