Cody

# Problem 45171. Squares in Squares - Concentric Squares

Solution 1971518

Submitted on 11 Oct 2019 by Kiran Ramsaroop
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 = 7; S_correct = ... [1 1 1 1 1 1 1; 1 0 0 0 0 0 1; 1 0 1 1 1 0 1; 1 0 1 0 1 0 1; 1 0 1 1 1 0 1; 1 0 0 0 0 0 1; 1 1 1 1 1 1 1]; Sn_correct = 2; [S,Sn] = squaresinsquares(n); assert(isequal(S,S_correct)); assert(isequal(Sn,Sn_correct));

Sn = 2 Sn = 3 Sn = 4

2   Pass
n = 2; S_correct = [1 1; 1 1]; Sn_correct = 1; [S,Sn] = squaresinsquares(n); assert(isequal(S,S_correct)); assert(isequal(Sn,Sn_correct));

3   Pass
n = 1; S_correct = 1; Sn_correct = 1; [S,Sn] = squaresinsquares(n); assert(isequal(S,S_correct)); assert(isequal(Sn,Sn_correct));

4   Pass
n = 10; Sn_correct = 3; [~,Sn] = squaresinsquares(n); assert(isequal(Sn,Sn_correct));

Sn = 2 Sn = 3 Sn = 4 Sn = 5

5   Pass
n = 6; S_correct = ... [1 1 1 1 1 1; 1 0 0 0 0 1; 1 0 1 1 0 1; 1 0 1 1 0 1; 1 0 0 0 0 1; 1 1 1 1 1 1]; Sn_correct = 2; [S,Sn] = squaresinsquares(n); assert(isequal(S,S_correct)); assert(isequal(Sn,Sn_correct));

Sn = 2 Sn = 3

### Community Treasure Hunt

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

Start Hunting!