Problem 44238. Mastermind III: Solve in 1
Mastermind is a code breaking logic puzzle. A pattern of 6 colors(values 1:6) of four positions (1111;1112;....6666) for a possible 6^4(1296) cases is generated. The solver plays a length 4 vector with values 1:6. Accuracy of the play is returned by a count of values in the right position and a count of values(excluding those in the right positions) common to the solution.
Answer:1233 Guess:3231 Response: 2,2 as x23x are right value/position, 3xx1 are right values.
[guess]=solve_mastermind(mguess,mpegs,m,mpc,mc,mpc5c,v)
where guess is a 1x4 vector, mguess is the kx4 matrix of prior guesses and is empty on first try, mpegs is kx2 giving right [value/position, values] for mguess, m is a 1296x4 array [1 1 1 1;...6 6 6 6] of all solutions, mpc is a 1296x1296 array of 0:4 for value/position solutions, mc is a 1296x1296 array of 0:4 for value solutions, mpc5c is state array of a combined mpc and pc of values 0:20, 5*mpc+mc, and v is integer value of solutions 1111 thru 6666.
Challenge: A set of 25 cases will be provided that have optimal guesses and their scores. Solve the pattern in 1 guess.
Theory: Elimination of excluded possible guesses will leave only one. Some solutions require only three total guesses so the input size will vary.
Future: Four Mastermind challenges will be created, [Solve no limit, Solve in 8 or less, Solve in 1 given a guess pattern, Solve in 5 or less]
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
Find relatively common elements in matrix rows
2051 Solvers
-
Recurring Cycle Length (Inspired by Project Euler Problem 26)
125 Solvers
-
68 Solvers
-
83 Solvers
-
282 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!