Cody

# Problem 43562. Mastermind

Solution 1208879

Submitted on 9 Jun 2017 by Michael
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
code = randi(6,1,4); % the real code to crack % attempt 1 attempts = []; attempts(1).code = [1 1 2 2]; % the first attempt % eval attempts(1).rightNumRightPlace = sum(code==attempts(1).code); attempts(1).rightNumWrongPlace = sum(sum(repmat(code',1,4)==repmat(attempts(1).code,4,1),2)>0)-attempts(1).rightNumRightPlace; attempts(1).userdata = []; % init solved = false; while (length(attempts)<11 && ~solved) attempts = mastermind(attempts); % eval attempts(end).rightNumRightPlace = sum(code==attempts(end).code); attempts(end).rightNumWrongPlace = sum(sum(repmat(code',1,4)==repmat(attempts(end).code,4,1),2)>0)-attempts(end).rightNumRightPlace; if attempts(end).rightNumRightPlace==4 solved = true; end end assert(solved)

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!