Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In python 3 In this problem, write a function mastermind (secret, turns) that plays this game given a list of integers secret of size at
In python 3
In this problem, write a function mastermind (secret, turns) that plays this game given a list of integers secret of size at least 2 and the maximum number of turns the guesser has to determine secret, and returns the number of guesses the guesser takes to determine the sequence. If secret is not guessed in turns guesses, the function returns None. Your interface file includes prompts for the guesser to select a sequence of numbers, for determining the number of elements in two lists that are in the same place, and determining the number of elements in two lists that match but are in different locations. You will also need to print text corresponding to: The number of numbers in the correct and incorrect locations, The number of guesses to determine the correct sequence, and you will need to take the following inputs from the keyboard once per round: A sequence of integers the same length of secret. The sample below shows possible interactions a user can have with your game that you must be able to replicate. You may assume that all user inputs are in accordance with the above description. In particular, the input for guesses will always be integers from 1 to 6 and will contain the same number of integers as secret. In addition, the guessed sequence will be input as one line of integers, separated by spaces. You may test the printing of your function with either set-print_exact or set_screen. Recall input prompts are not checked by set-print_exact. Sample: mastermind ([1,6,1,4], 5) => 4 given the following interactions: Enter your guess : 1 2 3 4 There are 2 numbers in correct places and O numbers in incorrect places. Enter your guess: 6 2 3 5 There are 0 numbers in correct places and 1 numbers in incorrect places. Enter your guess : 1 1 6 4 There are 2 numbers in correct places and 2 numbers in incorrect places. Enter your guess: 1 6 1 4 Sequence found in 4 guessesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started