Cody

Solution 1681077

Submitted on 27 Nov 2018 by Martin C.
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
A = magic(4); correct = 15; assert(isequal(minimax(A),correct))

cand = [] z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 maxi = 16 14 15 13 maxit = 16 11 12 15 cand = 16 out = 16 out = 16 out = 16 cand = 16 15 out = 15

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

cand = [] z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 maxi = 23 24 25 21 22 maxit = 24 23 22 21 25 cand = 24 out = 24 cand = 24 23 out = 23 cand = 24 23 22 out = 22 cand = 24 23 22 21 out = 21 cand = 24 23 22 21 25 out = 21

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

cand = [] z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 maxi = 152 153 151 143 144 142 maxit = 152 149 148 150 151 153 cand = 152 out = 152 out = 152 out = 152 out = 152 cand = 152 151 out = 151 cand = 152 151 153 out = 151

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

cand = [] z = 0 0 0 0 0 0 0 0 0 maxi = 6 4 5 maxit = 3 5 6 out = [] cand = 5 out = 5 cand = 5 6 out = 5

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

cand = [] z = 0 0 0 0 0 0 0 0 0 maxi = 6 4 5 maxit = 3 4 6 out = [] cand = 4 out = 4 cand = 4 6 out = 4

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

cand = [] z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 maxi = 6.8204 3.8002 7.1829 2.6436 1.7205 5.7604 4.1164 maxit = 6.8204 3.8002 7.1829 2.6436 1.7205 5.7604 4.1164 cand = 6.8204 out = 6.8204 cand = 6.8204 3.8002 out = 3.8002 cand = 6.8204 3.8002 7.1829 out = 3.8002 cand = 6.8204 3.8002 7.1829 2.6436 out = 2.6436 cand = 6.8204 3.8002 7.1829 2.6436 1.7205 out = 1.7205 cand = 6.8204 3.8002 7.1829 2.6436 1.7205 5.7604 out = 1.7205 cand = 6.8204 3.8002 7.1829 2.6436 1.7205 5.7604 4.1164 out = 1.7205

7   Pass
B = [1 2 1; 0 1 0]; correct = 2; assert(isequal(minimax(B),correct))

cand = [] z = 0 0 0 0 0 0 maxi = 1 2 1 maxit = 2 1 cand = 2 out = 2 out = 2

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

cand = [] z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 maxi = 70 64 61 55 61 61 maxit = 70 64 61 55 61 61 cand = 70 out = 70 cand = 70 64 out = 64 cand = 70 64 61 out = 61 out = 61 cand = 70 64 61 61 out = 61 out = 61

Suggested Problems

More from this Author41