Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 319309

Submitted on 14 Sep 2013 by @bmtran

Correct

69Size
Leading solution size is 25.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
A = magic(4);
correct = 15;
assert(isequal(minimax(A),correct))

                    
2
Pass
 
%%
A = magic(5);
correct = 21;
assert(isequal(minimax(A),correct))

                    
3
Pass
 
%%
A = magic(6);
n = randi(1024);
correct = 34;
assert(isequal(minimax(A+n),correct+n))

                    
4
Pass
 
%%
A = [1 2 3; 0 4 5; 6 0 0];
correct = 5;
assert(isequal(minimax(A),correct))

                    
5
Pass
 
%%
A = [1 2 3; 0 4 0; 6 0 5];
correct = 4;
assert(isequal(minimax(A),correct))

                    
6
Pass
 
%%
A = rand(7)+diag(randperm(7));
assert(isequal(floor(minimax(A)),1))

                    
7
Pass
 
%% those may be difficult for some approaches
B = [1 2 1; 0 1 0];
correct = 2;
assert(isequal(minimax(B),correct))

                    
8
Pass
 
%%
B = magic(6)+magic(6)';
correct = 61;
assert(isequal(minimax(B),correct))
% other test suggestions highly welcome