Cody

# Problem 1088. Rank of magic square (for beginners)

Solution 1770015

Submitted on 2 Apr 2019 by Abdelfatah Teamah
• Size: 7
• 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
n = 20; r = 3; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
n = 4; r = 3; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
n = 15; r = 15; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
n = 18; r = 11; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

5   Pass
n = 16; r = 3; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
n = 170; r = 87; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
n = 112; r = 3; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint7 (line 4) In solutionTest (line 15)]

8   Pass
n = 170; r = 87; filetext = fileread('mag_rang.m'); assert(isequal(mag_rang(n),r)) assert(isempty(strfind(filetext, 'rank'))) assert(isempty(strfind(filetext, 'magic')))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In mag_rang (line 2) In ScoringEngineTestPoint8 (line 4) In solutionTest (line 17)]