Cody

# Problem 313. Pythagorean perfect squares: find the square of the hypotenuse and the length of the other side

Solution 105325

Submitted on 2 Jul 2012 by Aurelien Queffurust
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
%% seed=3;n=6; [Z,y] = findPerfectZ(seed,n); Z_correct = 25; y_correct = 4; assert(isequal(Z,Z_correct)); assert(isequal(y,y_correct));

list_perfect = Columns 1 through 10 1 4 9 16 25 36 49 64 81 100 Columns 11 through 15 121 144 169 196 225 tf = Columns 1 through 10 0 0 0 0 1 0 0 0 0 0 Columns 11 through 15 0 0 0 0 0 loc = Columns 1 through 10 0 0 0 0 4 0 0 0 0 0 Columns 11 through 15 0 0 0 0 0

2   Pass
%% seed=5;n=15; [Z,y] = findPerfectZ(seed,n); Z_correct = 169; y_correct = 12; assert(isequal(Z,Z_correct)); assert(isequal(y,y_correct));

list_perfect = Columns 1 through 10 1 4 9 16 25 36 49 64 81 100 Columns 11 through 15 121 144 169 196 225 tf = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 Columns 11 through 15 0 0 1 0 0 loc = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 Columns 11 through 15 0 0 12 0 0

3   Pass
%% seed=4;n=6; [Z,y] = findPerfectZ(seed,n); Z_correct = 25; y_correct = 3; assert(isequal(Z,Z_correct)); assert(isequal(y,y_correct));

list_perfect = Columns 1 through 10 1 4 9 16 25 36 49 64 81 100 Columns 11 through 15 121 144 169 196 225 tf = Columns 1 through 10 0 0 0 0 1 0 0 0 0 0 Columns 11 through 15 0 0 0 0 0 loc = Columns 1 through 10 0 0 0 0 3 0 0 0 0 0 Columns 11 through 15 0 0 0 0 0

4   Pass
%% seed=12;n=15; [Z,y] = findPerfectZ(seed,n); Z_correct = 169; y_correct = 5; assert(isequal(Z,Z_correct)); assert(isequal(y,y_correct));

list_perfect = Columns 1 through 10 1 4 9 16 25 36 49 64 81 100 Columns 11 through 15 121 144 169 196 225 tf = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 Columns 11 through 15 0 0 1 0 1 loc = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 Columns 11 through 15 0 0 5 0 9

5   Pass
%% seed=6;n=9; [Z,y] = findPerfectZ(seed,n); Z_correct = 100; y_correct = 8; assert(isequal(Z,Z_correct)); assert(isequal(y,y_correct));

list_perfect = Columns 1 through 10 1 4 9 16 25 36 49 64 81 100 Columns 11 through 15 121 144 169 196 225 tf = Columns 1 through 10 0 0 0 0 0 0 0 0 0 1 Columns 11 through 15 0 0 0 0 0 loc = Columns 1 through 10 0 0 0 0 0 0 0 0 0 8 Columns 11 through 15 0 0 0 0 0

6   Pass
%% seed=8;n=9; [Z,y] = findPerfectZ(seed,n); Z_correct = 100; y_correct = 6; assert(isequal(Z,Z_correct)); assert(isequal(y,y_correct));

list_perfect = Columns 1 through 10 1 4 9 16 25 36 49 64 81 100 Columns 11 through 15 121 144 169 196 225 tf = Columns 1 through 10 0 0 0 0 0 0 0 0 0 1 Columns 11 through 15 0 0 0 0 0 loc = Columns 1 through 10 0 0 0 0 0 0 0 0 0 6 Columns 11 through 15 0 0 0 0 0

### Community Treasure Hunt

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

Start Hunting!