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.
Similar Kata:
Stats:
Created | Apr 14, 2020 |
Published | Apr 15, 2020 |
Warriors Trained | 215 |
Total Skips | 129 |
Total Code Submissions | 295 |
Total Times Completed | 25 |
Python Completions | 25 |
Total Stars | 5 |
% of votes with a positive feedback rating | 69% of 13 |
Total "Very Satisfied" Votes | 7 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |