Cody

# Problem 42685. Cody meets Xiangqi: foresee the unseen (Part 2)

Solution 777471

Submitted on 12 Nov 2015 by Alfonso Nieto-Castanon
• Size: 3
• This is the leading solution.
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
%% % Thanks to Alfonso Nieto-Castanon urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&amp;d=1','SetSolutionScore.p'); rehash path;

2   Pass

3   Pass
%% fid = fopen('Xiangqi2.m'); delim = {' ', '\n', ',', '.', ';', '''', '@', '+', '-', '*', '/', '\', '^', '>', '<', '=', '&', '|', '~', '{', '}', '[', ']', '(', ')'}; file = textscan(fid, '%s', 'CommentStyle', '%', 'MultipleDelimsAsOne', 1, 'Delimiter', delim); fclose(fid); assert(~any(ismember({'rng','RandStream','seed','state','twister','shufle','default'},file{1})));

4   Pass
%% a = 0; b = 0; Na = 2; Nb = 3; Nc = 2; tol = 1e-6; EvaluateSolution(a, b, Na, Nb, Nc, tol);

5   Pass
%% a = 0; b = 1; Na = 1; Nb = 2; Nc = 1; tol = 1e-6; EvaluateSolution(a, b, Na, Nb, Nc, tol);

6   Pass
%% a = 1; b = 0; Na = 3; Nb = 2; Nc = 1; tol = 1e-6; EvaluateSolution(a, b, Na, Nb, Nc, tol);

7   Pass
%% a = 0.15; b = 0.85; Na = 4; Nb = 2; Nc = 1; tol = 1e-4; EvaluateSolution(a, b, Na, Nb, Nc, tol);

8   Pass
%% a = 0.9; b = 0; Na = 3; Nb = 1; Nc = 2; tol = 1e-3; EvaluateSolution(a, b, Na, Nb, Nc, tol);

9   Pass
%% a = 0.65; b = 0.3; Na = 3; Nb = 2; Nc = 2; tol = 1e-3; EvaluateSolution(a, b, Na, Nb, Nc, tol);

10   Pass
%% Na = 3; Nb = 2; Nc = 1; tol = 2e-3; p = sort(rand(2,30)); p = sort([p(1,:);diff(p);1-p(2,:)]); for k = size(p,2):-1:1 a = p(3,k); b = p(2,k); score(k) = EvaluateSolution(a, b, Na, Nb, Nc, tol); end SetSolutionScore(round(mean(score)));

### Community Treasure Hunt

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

Start Hunting!