Cody

# Problem 44476. How many unique Pythagorean triples?

Solution 2161970

Submitted on 16 Mar 2020
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
filetext = fileread('triples.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

Error using fileread (line 23) Could not open file triples.m. No such file or directory. Error in Test1 (line 1) filetext = fileread('triples.m');

2   Fail
n = 1; mat_correct = []; assert(isequal(triples(n),mat_correct))

Undefined function 'triples' for input arguments of type 'double'. Error in Test2 (line 3) assert(isequal(triples(n),mat_correct))

3   Fail
n = 20.5; mat_correct = []; assert(isequal(triples(n),mat_correct))

Undefined function 'triples' for input arguments of type 'double'. Error in Test3 (line 3) assert(isequal(triples(n),mat_correct))

4   Fail
n = 15; mat_correct = [3, 4, 5; 5, 12, 13; 6, 8, 10; 9, 12, 15]; assert(isequal(triples(n),mat_correct))

Undefined function 'triples' for input arguments of type 'double'. Error in Test4 (line 3) assert(isequal(triples(n),mat_correct))

5   Fail
n = 16; mat_correct = [3, 4, 5; 5, 12, 13; 6, 8, 10; 9, 12, 15]; assert(isequal(triples(n),mat_correct))

Undefined function 'triples' for input arguments of type 'double'. Error in Test5 (line 3) assert(isequal(triples(n),mat_correct))

6   Pass
n = 100 mat_correct = ... [3 4 5; 5 12 13; 6 8 10; 7 24 25; 8 15 17; 9 12 15; 9 40 41; 10 24 26; 11 60 61; 12 16 20; 12 35 37; 13 84 85; 14 48 50; 15 20 25; 15 36 39; 16 30 34; 16 63 65; 18 24 30; 18 80 82; 20 21 29; 20 48 52; 21 28 35; 21 72 75; 24 32 40; 24 45 51; 24 70 74; 25 60 65; 27 36 45; 28 45 53; 28 96 100; 30 40 50; 30 72 78; 32 60 68; 33 44 55; 33 56 65; 35 84 91; 36 48 60; 36 77 85; 39 52 65; 39 80 89; 40 42 58; 40 75 85; 42 56 70; 45 60 75; 48 55 73; 48 64 80; 51 68 85; 54 72 90; 57 76 95; 60 63 87; 60 80 100; 65 72 97];

n = 100

7   Fail
n = 1000; s_correct = [881, 3]; assert(isequal(size(triples(n)), s_correct))

Undefined function 'triples' for input arguments of type 'double'. Error in Test7 (line 3) assert(isequal(size(triples(n)), s_correct))