Cody

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

Solution 1032174

Submitted on 26 Oct 2016
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   Fail
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));

Undefined function or variable 'flg'. Error in findPerfectZ (line 5) if (floor(a)==ceil(a) && flg==0) Error in TestPoint1 (line 3) [Z,y] = findPerfectZ(seed,n);

2   Fail
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));

Undefined function or variable 'flg'. Error in findPerfectZ (line 5) if (floor(a)==ceil(a) && flg==0) Error in TestPoint2 (line 3) [Z,y] = findPerfectZ(seed,n);

3   Fail
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));

Undefined function or variable 'flg'. Error in findPerfectZ (line 5) if (floor(a)==ceil(a) && flg==0) Error in TestPoint3 (line 3) [Z,y] = findPerfectZ(seed,n);

4   Fail
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));

Undefined function or variable 'flg'. Error in findPerfectZ (line 5) if (floor(a)==ceil(a) && flg==0) Error in TestPoint4 (line 3) [Z,y] = findPerfectZ(seed,n);

5   Fail
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));

Undefined function or variable 'flg'. Error in findPerfectZ (line 5) if (floor(a)==ceil(a) && flg==0) Error in TestPoint5 (line 3) [Z,y] = findPerfectZ(seed,n);

6   Fail
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));

Undefined function or variable 'flg'. Error in findPerfectZ (line 5) if (floor(a)==ceil(a) && flg==0) Error in TestPoint6 (line 3) [Z,y] = findPerfectZ(seed,n);

Suggested Problems

More from this Author16

Community Treasure Hunt

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

Start Hunting!