Cody

# Problem 2022. Find a Pythagorean triple

Solution 1978469

Submitted on 16 Oct 2019 by Alvin LAU
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 = 1; b = 2; c = 3; d = 4; flag_correct = false; assert(isequal(isTherePythagoreanTriple(a, b, c, d),flag_correct))

x = 1 4 9 16 x(:,:,1) = 1 2 7 14 4 1 4 11 9 6 1 6 16 13 8 1 x(:,:,2) = 4 1 4 11 7 4 1 8 12 9 4 3 19 16 11 4 x(:,:,3) = 9 6 1 6 12 9 4 3 17 14 9 2 24 21 16 9 x(:,:,4) = 16 13 8 1 19 16 11 4 24 21 16 9 31 28 23 16 ans = logical 0

2   Pass
a = 2; b = 3; c = 4; d = 5; flag_correct = true; assert(isequal(isTherePythagoreanTriple(a, b, c, d),flag_correct))

x = 4 9 16 25 x(:,:,1) = 4 1 8 17 9 4 3 12 16 11 4 5 25 20 13 4 x(:,:,2) = 9 4 3 12 14 9 2 7 21 16 9 0 30 25 18 9 x(:,:,3) = 16 11 4 5 21 16 9 0 28 23 16 7 37 32 25 16 x(:,:,4) = 25 20 13 4 30 25 18 9 37 32 25 16 46 41 34 25 ans = logical 1

3   Pass
a = 3; b = 4; c = 5; d = 6; flag_correct = true; assert(isequal(isTherePythagoreanTriple(a, b, c, d),flag_correct))

x = 9 16 25 36 x(:,:,1) = 9 2 7 18 16 9 0 11 25 18 9 2 36 29 20 9 x(:,:,2) = 16 9 0 11 23 16 7 4 32 25 16 5 43 36 27 16 x(:,:,3) = 25 18 9 2 32 25 16 5 41 34 25 14 52 45 36 25 x(:,:,4) = 36 29 20 9 43 36 27 16 52 45 36 25 63 56 47 36 ans = logical 1

4   Pass
a = 3; b = 4; c = 4.5; d = 5; flag_correct = true; assert(isequal(isTherePythagoreanTriple(a, b, c, d),flag_correct))

x = 9.0000 16.0000 20.2500 25.0000 x(:,:,1) = 9.0000 2.0000 2.2500 7.0000 16.0000 9.0000 4.7500 0 20.2500 13.2500 9.0000 4.2500 25.0000 18.0000 13.7500 9.0000 x(:,:,2) = 16.0000 9.0000 4.7500 0 23.0000 16.0000 11.7500 7.0000 27.2500 20.2500 16.0000 11.2500 32.0000 25.0000 20.7500 16.0000 x(:,:,3) = 20.2500 13.2500 9.0000 4.2500 27.2500 20.2500 16.0000 11.2500 31.5000 24.5000 20.2500 15.5000 36.2500 29.2500 25.0000 20.2500 x(:,:,4) = 25.0000 18.0000 13.7500 9.0000 32.0000 25.0000 20.7500 16.0000 36.2500 29.2500 25.0000 20.2500 41.0000 34.0000 29.7500 25.0000 ans = logical 1

5   Pass
a = 3; b = 3.5; c = 4; d = 5; flag_correct = true; assert(isequal(isTherePythagoreanTriple(a, b, c, d),flag_correct))

x = 9.0000 12.2500 16.0000 25.0000 x(:,:,1) = 9.0000 5.7500 2.0000 7.0000 12.2500 9.0000 5.2500 3.7500 16.0000 12.7500 9.0000 0 25.0000 21.7500 18.0000 9.0000 x(:,:,2) = 12.2500 9.0000 5.2500 3.7500 15.5000 12.2500 8.5000 0.5000 19.2500 16.0000 12.2500 3.2500 28.2500 25.0000 21.2500 12.2500 x(:,:,3) = 16.0000 12.7500 9.0000 0 19.2500 16.0000 12.2500 3.2500 23.0000 19.7500 16.0000 7.0000 32.0000 28.7500 25.0000 16.0000 x(:,:,4) = 25.0000 21.7500 18.0000 9.0000 28.2500 25.0000 21.2500 12.2500 32.0000 28.7500 25.0000 16.0000 41.0000 37.7500 34.0000 25.0000 ans = logical 1