Cody

# Problem 44476. How many unique Pythagorean triples?

Solution 2077338

Submitted on 2 Jan 2020 by malik malichov
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))

mat = []

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

mat = []

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

v = 3 4 5 v = 5 12 13 v = 6 8 10 v = 9 12 15 mat = 3 4 5 5 12 13 6 8 10 9 12 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))

v = 3 4 5 v = 5 12 13 v = 6 8 10 v = 9 12 15 mat = 3 4 5 5 12 13 6 8 10 9 12 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))

v = 3 4 5 v = 5 12 13 v = 6 8 10 v = 7 24 25 v = 8 15 17 v = 9 12 15 v = 9 40 41 v = 10 24 26 v = 11 60 61 v = 12 16 20 v = 12 35 37 v = 13 84 85 v = 14 48 50 v = 15 20 25 v = 15 36 39 v = 15 112 113 v = 16 30 34 v = 16 63 65 v = 17 144 145 v = 18 24 30 v = 18 80 82 v = 19 180 181 v = 20 21 29 v = 20 48 52 v = 20 99 101 v = 21 28 35 v = 21 72 75 v = 21 220 221 v = 22 120 122 v = 23 264 265 v = 24 32 40 v = 24 45 51 v = 24 70 74 v = 24 143 145 v = 25 60 65 v = 25 312 313 v = 26 168 170 v = 27 36 45 v = 27 120 123 v = 27 364 365 v = 28 45 53 v = 28 96 100 v = 28 195 197 v = 29 420 421 v = 30 40 50 v = 30 72 78 v = 30 224 226 v = 31 480 481 v = 32 60 68 v = 32 126 130 v = 32 255 257 v = 33 44 55 v = 33 56 65 v = 33 180 183 v = 33 544 545 v = 34 288 290 v = 35 84 91 v = 35 120 125 v = 35 612 613 v = 36 48 60 v = 36 77 85 v = 36 105 111 v = 36 160 164 v = 36 323 325 v = 37 684 685 v = 38 360 362 v = 39 52 65 v = 39 80 89 v = 39 252 255 v = 39 760 761 v = 40 42 58 v = 40 75 85 v = 40 96 104 v = 40 198 202 v = 40 399 401 v = 41 840 841 v = 42 56 70 v = 42 144 150 v = 42 440 442 v = 43 924 925 v = 44 117 125 v = 44 240 244 v = 44 483 485 v = 45 60 75 v = 45 108 117 v = 45 200 205 v = 45 336 339 v = 46 528 530 v = 48 55 73 v = 48 64 80 v = 48 90 102 v = 48 140 148 v = 48 189 195 v = 48 286 290 v = 48 575 577 v = 49 168 175 v = 50 120 130 v = 50 624 626 v = 51 68 85 v = 51 140 149 v = 51 432 435 v = 52 165 173 v = 52 336 340 v = 52 675 677 v = 54 72 90 v = 54 240 246 v = 54 728 730 v = 55 132 143 v = 55 300 305 v = 56 90 106 v = 56 105 119 v = 56 192 200 v = 56 390 394 v = 56 783 785 v = 57 76 95 v = 57 176 185 v = 57 540 543 v = 58 840 842 v = 60 63 87 v = 60 80 100 v = 60 91 109 v = 60 144 156 v = 60 175 185 v = 60 221 229 v = 60 297 303 v = 60 448 452 v = 60 899 901 v = 62 960 962 v = 63 84 105 v = 63 216 225 v = 63 280 287 v = 63 660 663 v = 64 120 136 v = 64 252 260 v = 64 510 514 v = 65 72 97 v = 65 156 169 v = 65 420 425 v = 66 88 110 v = 66 112 130 v = 66 360 366 v = 68 285 293 v = 68 576 580 v = 69 92 115 v = 69 260 269 v = 69 792 795 v = 70 168 182 v = 70 240 250 v = 72 96 120 v = 72 135 153 v = 72 154 170 v = 72 210 222 v = 72 320 328 v = 72 429 435 v = 72 646 650 v = 75 100 125 v = 75 180 195 v = 75 308 317 v = 75 560 565 v = 75 936 939 v = 76 357 365 v = 76 720 724 v = 77 264 275 v = 77 420 427 v = 78 104 130 v = 78 160 178 v = 78 504 510 v = 80 84 116 v = 80 150 170 v = 80 192 208 v = 80 315 325 v = 80 396 404 v = 80 798 802 v = 81 108 135 v = 81 360 369 v = 84 112 140 v = 84 135 159 v = 84 187 205 v = 84 245 259 v = 84 288 300 v = 84 437 445 v = 84 585 591 v = 84 880 884 v = 85 132 157 v = 85 204 221 v = 85 720 725 v = 87 116 145 v = 87 416 425 v = 88 105 137 v = 88 165 187 v = 88 234 250 v = 88 480 488 v = 88 966 970 v = 90 120 150 v = 90 216 234 v = 90 400 410 v = 90 672 678 v = 91 312 325 v = 91 588 595 v = 92 525 533 v = 93 124 155 v = 93 476 485 v = 95 168 193 v = 95 228 247 v = 95 900 905 v = 96 110 146 v = 96 128 160 v = 96 180 204 v = 96 247 265 v = 96 280 296 v = 96 378 390 v = 96 572 580 v = 96 765 771 v = 98 336 350 v = 99 132 165 v = 99 168 195 v = 99 440 451 v = 99 540 549 v = 100 105 145 v = 100 240 260 v = 100 495 505 v = 100 621 629 v = 102 136 170 v = 102 280 298 v = 102 864 870 v = 104 153 185 v = 104 195 221 v = 104 330 346 v = 104 672 680 v = 105 140 175 v = 105 208 233 v = 105 252 273 v = 105 360 375 v = 105 608 617 v = 105 784 791 v = 108 144 180 v = 108 231 255 v = 108 315 333 v = 108 480 492 v = 108 725 733 v = 108 969 975 v = 110 264 286 v = 110 600 610 v = 111 148 185 v = 111 680 689 v = 112 180 212 v = 112 210 238 v = 112 384 400 v = 112 441 455 v = 112 780 788 v = 114 152 190 v = 114 352 370 v = 115 252 277 v = 115 276 299 v = 116 837 845 v = 117 156 195 v = 117 240 267 v = 117 520 533 v = 117 756 765 v = 119 120 169 v = 119 408 425 v = 120 126 174 v = 120 160 200 v = 120 182 218 v = 120 209 241 v = 120 225 255 v = 120 288 312 v = 120 350 370 v = 120 391 409 v = 120 442 458 v = 120 594 606 v = 120 715 725 v = 120 896 904 v = 121 660 671 v = 123 164 205 v = 123 836 845 v = 124 957 965 v = 125 300 325 v = 126 168 210 v = 126 432 450 v = 126 560 574 v = 128 240 272 v = 128 504 520 v = 129 172 215 v = 129 920 929 v = 130 144 194 v = 130 312 338 v = 130 840 850 v = 132 176 220 v = 132 224 260 v = 132 351 375 v = 132 385 407 v = 132 475 493 v = 132 720 732 v = 133 156 205 v = 133 456 475 v = 135 180 225 v = 135 324 351 v = 135 352 377 v = 135 600 615 v = 136 255 289 v = 136 273 305 v = 136 570 586 v = 138 184 230 v = 138 520 538 v = 140 147 203 v = 140 171 221 v = 140 225 265 v = 140 336 364 v = 140 480 500 v = 140 693 707 v = 140 975 985 v = 141 188 235 v = 143 780 793 v = 143 924 935 v = 144 165 219 v = 144 192 240 v = 144 270 306 v = 144 308 340 v = 144 420 444 v = 144 567 585 v = 144 640 656 v = 144 858 870 v = 145 348 377 v = 145 408 433 v = 147 196 245 v = 147 504 525 v = 150 200 250 v = 150 360 390 v = 150 616 634 v = 152 285 323 v = 152 345 377 v = 152 714 730 v = 153 204 255 v = 153 420 447 v = 153 680 697 v = 154 528 550 v = 154 840 854 v = 155 372 403 v = 155 468 493 v = 156 208 260 v = 156 320 356 v = 156 455 481 v = 156 495 519 v = 156 667 685 v = 159 212 265 v = 160 168 232 v = 160 231 281 v = 160 300 340 v = 160 384 416 v = 160 630 650 v = 160 792 808 v = 161 240 289 v = 161 552 575 v = 162 216 270 v = 162 720 738 v = 165 220 275 v = ...