Cody

Problem 44476. How many unique Pythagorean triples?

Solution 1554222

Submitted on 8 Jun 2018 by tamir ben shitrit
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
filetext = fileread('triples.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

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

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

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

a is = 3 , b is =4 , c2 is = 5 a is = 5 , b is =12 , c2 is = 13 a is = 6 , b is =8 , c2 is = 10 a is = 9 , b is =12 , c2 is = 15

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

a is = 3 , b is =4 , c2 is = 5 a is = 5 , b is =12 , c2 is = 13 a is = 6 , b is =8 , c2 is = 10 a is = 9 , b is =12 , c2 is = 15

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   Pass
n = 1000; s_correct = [881, 3]; assert(isequal(size(triples(n)), s_correct))

a is = 3 , b is =4 , c2 is = 5 a is = 5 , b is =12 , c2 is = 13 a is = 6 , b is =8 , c2 is = 10 a is = 7 , b is =24 , c2 is = 25 a is = 8 , b is =15 , c2 is = 17 a is = 9 , b is =12 , c2 is = 15 a is = 9 , b is =40 , c2 is = 41 a is = 10 , b is =24 , c2 is = 26 a is = 11 , b is =60 , c2 is = 61 a is = 12 , b is =16 , c2 is = 20 a is = 12 , b is =35 , c2 is = 37 a is = 13 , b is =84 , c2 is = 85 a is = 14 , b is =48 , c2 is = 50 a is = 15 , b is =20 , c2 is = 25 a is = 15 , b is =36 , c2 is = 39 a is = 15 , b is =112 , c2 is = 113 a is = 16 , b is =30 , c2 is = 34 a is = 16 , b is =63 , c2 is = 65 a is = 17 , b is =144 , c2 is = 145 a is = 18 , b is =24 , c2 is = 30 a is = 18 , b is =80 , c2 is = 82 a is = 19 , b is =180 , c2 is = 181 a is = 20 , b is =21 , c2 is = 29 a is = 20 , b is =48 , c2 is = 52 a is = 20 , b is =99 , c2 is = 101 a is = 21 , b is =28 , c2 is = 35 a is = 21 , b is =72 , c2 is = 75 a is = 21 , b is =220 , c2 is = 221 a is = 22 , b is =120 , c2 is = 122 a is = 23 , b is =264 , c2 is = 265 a is = 24 , b is =32 , c2 is = 40 a is = 24 , b is =45 , c2 is = 51 a is = 24 , b is =70 , c2 is = 74 a is = 24 , b is =143 , c2 is = 145 a is = 25 , b is =60 , c2 is = 65 a is = 25 , b is =312 , c2 is = 313 a is = 26 , b is =168 , c2 is = 170 a is = 27 , b is =36 , c2 is = 45 a is = 27 , b is =120 , c2 is = 123 a is = 27 , b is =364 , c2 is = 365 a is = 28 , b is =45 , c2 is = 53 a is = 28 , b is =96 , c2 is = 100 a is = 28 , b is =195 , c2 is = 197 a is = 29 , b is =420 , c2 is = 421 a is = 30 , b is =40 , c2 is = 50 a is = 30 , b is =72 , c2 is = 78 a is = 30 , b is =224 , c2 is = 226 a is = 31 , b is =480 , c2 is = 481 a is = 32 , b is =60 , c2 is = 68 a is = 32 , b is =126 , c2 is = 130 a is = 32 , b is =255 , c2 is = 257 a is = 33 , b is =44 , c2 is = 55 a is = 33 , b is =56 , c2 is = 65 a is = 33 , b is =180 , c2 is = 183 a is = 33 , b is =544 , c2 is = 545 a is = 34 , b is =288 , c2 is = 290 a is = 35 , b is =84 , c2 is = 91 a is = 35 , b is =120 , c2 is = 125 a is = 35 , b is =612 , c2 is = 613 a is = 36 , b is =48 , c2 is = 60 a is = 36 , b is =77 , c2 is = 85 a is = 36 , b is =105 , c2 is = 111 a is = 36 , b is =160 , c2 is = 164 a is = 36 , b is =323 , c2 is = 325 a is = 37 , b is =684 , c2 is = 685 a is = 38 , b is =360 , c2 is = 362 a is = 39 , b is =52 , c2 is = 65 a is = 39 , b is =80 , c2 is = 89 a is = 39 , b is =252 , c2 is = 255 a is = 39 , b is =760 , c2 is = 761 a is = 40 , b is =42 , c2 is = 58 a is = 40 , b is =75 , c2 is = 85 a is = 40 , b is =96 , c2 is = 104 a is = 40 , b is =198 , c2 is = 202 a is = 40 , b is =399 , c2 is = 401 a is = 41 , b is =840 , c2 is = 841 a is = 42 , b is =56 , c2 is = 70 a is = 42 , b is =144 , c2 is = 150 a is = 42 , b is =440 , c2 is = 442 a is = 43 , b is =924 , c2 is = 925 a is = 44 , b is =117 , c2 is = 125 a is = 44 , b is =240 , c2 is = 244 a is = 44 , b is =483 , c2 is = 485 a is = 45 , b is =60 , c2 is = 75 a is = 45 , b is =108 , c2 is = 117 a is = 45 , b is =200 , c2 is = 205 a is = 45 , b is =336 , c2 is = 339 a is = 46 , b is =528 , c2 is = 530 a is = 48 , b is =55 , c2 is = 73 a is = 48 , b is =64 , c2 is = 80 a is = 48 , b is =90 , c2 is = 102 a is = 48 , b is =140 , c2 is = 148 a is = 48 , b is =189 , c2 is = 195 a is = 48 , b is =286 , c2 is = 290 a is = 48 , b is =575 , c2 is = 577 a is = 49 , b is =168 , c2 is = 175 a is = 50 , b is =120 , c2 is = 130 a is = 50 , b is =624 , c2 is = 626 a is = 51 , b is =68 , c2 is = 85 a is = 51 , b is =140 , c2 is = 149 a is = 51 , b is =432 , c2 is = 435 a is = 52 , b is =165 , c2 is = 173 a is = 52 , b is =336 , c2 is = 340 a is = 52 , b is =675 , c2 is = 677 a is = 54 , b is =72 , c2 is = 90 a is = 54 , b is =240 , c2 is = 246 a is = 54 , b is =728 , c2 is = 730 a is = 55 , b is =132 , c2 is = 143 a is = 55 , b is =300 , c2 is = 305 a is = 56 , b is =90 , c2 is = 106 a is = 56 , b is =105 , c2 is = 119 a is = 56 , b is =192 , c2 is = 200 a is = 56 , b is =390 , c2 is = 394 a is = 56 , b is =783 , c2 is = 785 a is = 57 , b is =76 , c2 is = 95 a is = 57 , b is =176 , c2 is = 185 a is = 57 , b is =540 , c2 is = 543 a is = 58 , b is =840 , c2 is = 842 a is = 60 , b is =63 , c2 is = 87 a is = 60 , b is =80 , c2 is = 100 a is = 60 , b is =91 , c2 is = 109 a is = 60 , b is =144 , c2 is = 156 a is = 60 , b is =175 , c2 is = 185 a is = 60 , b is =221 , c2 is = 229 a is = 60 , b is =297 , c2 is = 303 a is = 60 , b is =448 , c2 is = 452 a is = 60 , b is =899 , c2 is = 901 a is = 62 , b is =960 , c2 is = 962 a is = 63 , b is =84 , c2 is = 105 a is = 63 , b is =216 , c2 is = 225 a is = 63 , b is =280 , c2 is = 287 a is = 63 , b is =660 , c2 is = 663 a is = 64 , b is =120 , c2 is = 136 a is = 64 , b is =252 , c2 is = 260 a is = 64 , b is =510 , c2 is = 514 a is = 65 , b is =72 , c2 is = 97 a is = 65 , b is =156 , c2 is = 169 a is = 65 , b is =420 , c2 is = 425 a is = 66 , b is =88 , c2 is = 110 a is = 66 , b is =112 , c2 is = 130 a is = 66 , b is =360 , c2 is = 366 a is = 68 , b is =285 , c2 is = 293 a is = 68 , b is =576 , c2 is = 580 a is = 69 , b is =92 , c2 is = 115 a is = 69 , b is =260 , c2 is = 269 a is = 69 , b is =792 , c2 is = 795 a is = 70 , b is =168 , c2 is = 182 a is = 70 , b is =240 , c2 is = 250 a is = 72 , b is =96 , c2 is = 120 a is = 72 , b is =135 , c2 is = 153 a is = 72 , b is =154 , c2 is = 170 a is = 72 , b is =210 , c2 is = 222 a is = 72 , b is =320 , c2 is = 328 a is = 72 , b is =429 , c2 is = 435 a is = 72 , b is =646 , c2 is = 650 a is = 75 , b is =100 , c2 is = 125 a is = 75 , b is =180 , c2 is = 195 a is = 75 , b is =308 , c2 is = 317 a is = 75 , b is =560 , c2 is = 565 a is = 75 , b is =936 , c2 is = 939 a is = 76 , b is =357 , c2 is = 365 a is = 76 , b is =720 , c2 is = 724 a is = 77 , b is =264 , c2 is = 275 a is = 77 , b is =420 , c2 is = 427 a is = 78 , b is =104 , c2 is = 130 a is = 78 , b is =160 , c2 is = 178 a is = 78 , b is =504 , c2 is = 510 a is = 80 , b is =84 , c2 is = 116 a is = 80 , b is =150 , c2 is = 170 a is = 80 , b is =192 , c2 is = 208 a is = 80 , b is =315 , c2 is = 325 a is = 80 , b is =396 , c2 is = 404 a is = 80 , b is =798 , c2 is = 802 a is = 81 , b is =108 , c2 is = 135 a is = 81 , b is =360 , c2 is = 369 a is = 84 , b is =112 , c2 is = 140 a is = 84 , b is =135 , c2 is = 159 a is = 84 , b is =187 , c2 is = 205 a is = 84 , b is =245 , c2 is = 259 a is = 84 , b is =288 , c2 is = 300 a is = 84 , b is =437 , c2 is = 445 a is = 84 , b is =585 , c2 is = 591 a is = 84 , b is =880 , c2 is = 884 a is = 85 , b is =132 , c2 is = 157 a is = 85 , b is =204 , c2 is = 221 a is = 85 , b is =720 , c2 is = 725 a is = 87 , b is =116 , c2 is = 145 a is = 87 , b is =416 , c2 is = 425 a is = 88 , b is =105 , c2 is = 137 a is = 88 , b is =165 , c2 is = 187 a is = 88 , b is =234 , c2 is = 250 a is = 88 , b is =480 , c2 is = 488 a is = 88 , b is =966 , c2 is = 970 a is = 90 , b is =120 , c2 is = 150 a is = 90 , b is =216 , c2 is = 234 a is = 90 , b is =400 , c2 is = 410 a is = 90 , b is =672 , c2 is = 678 a is = 91 , b is =312 , c2 is = 325 a is = 91 , b is =588 , c2 is = 595 a is = 92 , b is =525 , c2 is = 533 a is = 93 , b is =124 , c2 is = 155 a is = 93 , b is =476 , c2 is = 485 a is = 95 , b is =168 , c2 is = 193 a is = 95 , b is =228 , c2 is = 247 a is = 95 , b is =900 , c2 is = 905 a is = 96 , b is =110 , c2 is = 146 a is = 96 , b is =128 , c2 is = 160 a is = 96 , b is =180 , c2 is = 204 a is = 96 , b is =247 , c2 is = 265 a is = 96 , b is =280 , c2 is = 296 a is = 96 , b is =378 , c2 is = 390 a is = 96 , b is =572 , c2 is = 580 a is = 96 , b is =765 , c2 is = 771 a is = 98 , b is =336 , c2 is = 350 a is = 99 , b is =132 , c2 is = 165 a is = 99 , b is =168 , c2 is = 195 a is = 99 , b is =440 , c2 is = 451 a is = 99 , b is =540 , c2 is = 549 a is = 100 , b is =105 , c2 is = 145 a is = 100 , b is =240 , c2 is = 260 a is = 100 , b is =495 , c2 is = 505 a is = 100 , b is =621 , c2 is = 629 a is = 102 , b is =136 , c2 is = 170 a is = 102 , b is =280 , c2 is = 298 a is = 102 , b is =864 , c2 is = 870 a is = 104 , b is =153 , c2 is = 185 a is = 104 , b is =195 , c2 is = 221 a is = 104 , b is =330 , c2 is = 346 a is = 104 , b is =672 , c2 is = 680 a is = 105 , b is =140 , c2 is = 175 a is = 105 , b is =208 , c2 is = 233 a is = 105 , b is =252 , c2 is = 273 a is = 105 , b is =360 , c2 is = 375 a is = 105 , b is =608 , c2 is = 617 a is = 105 , b is =784 , c2 is = 791 a is = 108 , b is =144 , c2 is = 180 a is = 108 , b is =231 , c2 is = 255 a is = 108 , b is =315 , c2 is = 333 a is = 108 , b is =480 , c2 is = 492 a is = 108 , b is =725 , c2 is = 733 a is = 108 , b is =969 , c2 is = 975 a is = 110 , b is =264 , c2 is = 286 a is = 110 , b is =600 , c2 is = 610 a is = 111 , b is =148 , c2 is = 185 a is = 111 , b is =680 , c2 is = 689 a is = 112 , b is =180 , c2 is = 212 a is = 112 , b is =210 , c2 is = 238 a is = 112 , b is =384 , c2 is = 400 a is = 112 , b is =441 , c2 is = 455 a is = 112 , b is =780 , c2 is = 788 a is = 114 , b is =152 , c2 is = 190 a is = 114 , b is =352 , c2 is = 370 a is = 115 , b is =252 , c2 is = 277 a is = 115 , b is =276 , c2 is = 299 a is = 116 , b is =837 , c2 is = 845 a is = 117 , b is =156 , c2 is = 195 a is = 117 , b is =240 , c2 is = 267 a is = 117 , b is =520 , c2 is = 533 a is = 117 , b is =756 , c2 is = 765 a is = 119 , b is =120 , c2 is = 169 a is = 119 , b is =408 , c2 is = 425 a is = 120 , b is =126 , c2 is = 174 a is = 120 , b is =160 , c2 is = 200 a is = 120 , b is =182 , c2 is = 218 a is = 120 , b is =209 , c2 is = 241 a is ...

Suggested Problems

More from this Author25

Community Treasure Hunt

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

Start Hunting!