Cody

Problem 44476. How many unique Pythagorean triples?

Solution 1410427

Submitted on 8 Jan 2018 by Yair Fridman
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))

d = 2 d = 3 d = 4 d = 5

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

d = 2 d = 3 d = 4 d = 5

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))

d = 2 d = 3 d = 4 d = 5 d = 6 d = 7 d = 8 d = 9 d = 10 d = 11 d = 12 d = 13 d = 14 d = 15 d = 16 d = 17 d = 18 d = 19 d = 20 d = 21 d = 22 d = 23 d = 24 d = 25 d = 26 d = 27 d = 28 d = 29 d = 30 d = 31 d = 32 d = 33 d = 34 d = 35 d = 36 d = 37 d = 38 d = 39 d = 40 d = 41 d = 42 d = 43 d = 44 d = 45 d = 46 d = 47 d = 48 d = 49 d = 50 d = 51 d = 52 d = 53 d = 54 d = 55 d = 56 d = 57 d = 58 d = 59 d = 60 d = 61 d = 62 d = 63 d = 64 d = 65 d = 66 d = 67 d = 68 d = 69 d = 70 d = 71 d = 72 d = 73 d = 74 d = 75 d = 76 d = 77 d = 78 d = 79 d = 80 d = 81 d = 82 d = 83 d = 84 d = 85 d = 86 d = 87 d = 88 d = 89 d = 90 d = 91 d = 92 d = 93 d = 94 d = 95 d = 96 d = 97 d = 98 d = 99 d = 100 d = 101 d = 102 d = 103 d = 104 d = 105 d = 106 d = 107 d = 108 d = 109 d = 110 d = 111 d = 112 d = 113 d = 114 d = 115 d = 116 d = 117 d = 118 d = 119 d = 120 d = 121 d = 122 d = 123 d = 124 d = 125 d = 126 d = 127 d = 128 d = 129 d = 130 d = 131 d = 132 d = 133 d = 134 d = 135 d = 136 d = 137 d = 138 d = 139 d = 140 d = 141 d = 142 d = 143 d = 144 d = 145 d = 146 d = 147 d = 148 d = 149 d = 150 d = 151 d = 152 d = 153 d = 154 d = 155 d = 156 d = 157 d = 158 d = 159 d = 160 d = 161 d = 162 d = 163 d = 164 d = 165 d = 166 d = 167 d = 168 d = 169 d = 170 d = 171 d = 172 d = 173 d = 174 d = 175 d = 176 d = 177 d = 178 d = 179 d = 180 d = 181 d = 182 d = 183 d = 184 d = 185 d = 186 d = 187 d = 188 d = 189 d = 190 d = 191 d = 192 d = 193 d = 194 d = 195 d = 196 d = 197 d = 198 d = 199 d = 200 d = 201 d = 202 d = 203 d = 204 d = 205 d = 206 d = 207 d = 208 d = 209 d = 210 d = 211 d = 212 d = 213 d = 214 d = 215 d = 216 d = 217 d = 218 d = 219 d = 220 d = 221 d = 222 d = 223 d = 224 d = 225 d = 226 d = 227 d = 228 d = 229 d = 230 d = 231 d = 232 d = 233 d = 234 d = 235 d = 236 d = 237 d = 238 d = 239 d = 240 d = 241 d = 242 d = 243 d = 244 d = 245 d = 246 d = 247 d = 248 d = 249 d = 250 d = 251 d = 252 d = 253 d = 254 d = 255 d = 256 d = 257 d = 258 d = 259 d = 260 d = 261 d = 262 d = 263 d = 264 d = 265 d = 266 d = 267 d = 268 d = 269 d = 270 d = 271 d = 272 d = 273 d = 274 d = 275 d = 276 d = 277 d = 278 d = 279 d = 280 d = 281 d = 282 d = 283 d = 284 d = 285 d = 286 d = 287 d = 288 d = 289 d = 290 d = 291 d = 292 d = 293 d = 294 d = 295 d = 296 d = 297 d = 298 d = 299 d = 300 d = 301 d = 302 d = 303 d = 304 d = 305 d = 306 d = 307 d = 308 d = 309 d = 310 d = 311 d = 312 d = 313 d = 314 d = 315 d = 316 d = 317 d = 318 d = 319 d = 320 d = 321 d = 322 d = 323 d = 324 d = 325 d = 326 d = 327 d = 328 d = 329 d = 330 d = 331 d = 332 d = 333 d = 334 d = 335 d = 336 d = 337 d = 338 d = 339 d = 340 d = 341 d = 342 d = 343 d = 344 d = 345 d = 346 d = 347 d = 348 d = 349 d = 350 d = 351 d = 352 d = 353 d = 354 d = 355 d = 356 d = 357 d = 358 d = 359 d = 360 d = 361 d = 362 d = 363 d = 364 d = 365 d = 366 d = 367 d = 368 d = 369 d = 370 d = 371 d = 372 d = 373 d = 374 d = 375 d = 376 d = 377 d = 378 d = 379 d = 380 d = 381 d = 382 d = 383 d = 384 d = 385 d = 386 d = 387 d = 388 d = 389 d = 390 d = 391 d = 392 d = 393 d = 394 d = 395 d = 396 d = 397 d = 398 d = 399 d = 400 d = 401 d = 402 d = 403 d = 404 d = 405 d = 406 d = 407 d = 408 d = 409 d = 410 d = 411 d = 412 d = 413 d = 414 d = 415 d = 416 d = 417 d = 418 d = 419 d = 420 d = 421 d = 422 d = 423 d = 424 d = 425 d = 426 d = 427 d = 428 d = 429 d = 430 d = 431 d = 432 d = 433 d = 434 d = 435 d = 436 d = 437 d = 438 d = 439 d = 440 d = 441 d = 442 d = 443 d = 444 d = 445 d = 446 d = 447 d = 448 d = 449 d = 450 d = 451 d = 452 d = 453 d = 454 d = 455 d = 456 d = 457 d = 458 d = 459 d = 460 d = 461 d = 462 d = 463 d = 464 d = 465 d = 466 d = 467 d = 468 d = 469 d = 470 d = 471 d = 472 d = 473 d = 474 d = 475 d = 476 d = 477 d = 478 d = 479 d = 480 d = 481 d = 482 d = 483 d = 484 d = 485 d = 486 d = 487 d = 488 d = 489 d = 490 d = 491 d = 492 d = 493 d = 494 d = 495 d = 496 d = 497 d = 498 d = 499 d = 500 d = 501 d = 502 d = 503 d = 504 d = 505 d = 506 d = 507 d = 508 d = 509 d = 510 d = 511 d = 512 d = 513 d = 514 d = 515 d = 516 d = 517 d = 518 d = 519 d = 520 d = 521 d = 522 d = 523 d = 524 d = 525 d = 526 d = 527 d = 528 d = 529 d = 530 d = 531 d = 532 d = 533 d = 534 d = 535 d = 536 d = 537 d = 538 d = 539 d = 540 d = 541 d = 542 d = 543 d = 544 d = 545 d = 546 d = 547 d = 548 d = 549 d = 550 d = 551 d = 552 d = 553 d = 554 d = 555 d = 556 d = 557 d = 558 d = 559 d = 560 d = 561 d = 562 d = 563 d = 564 d = 565 d = 566 d = 567 d = 568 d = 569 d = 570 d = 571 d = 572 d = 573 d = 574 d = 575 d = 576 d = 577 d = 578 d = 579 d = 580 d = 581 d = 582 d = 583 d = 584 d = 585 d = 586 d = 587 d = 588 d = 589 d = 590 d = 591 d = 592 d = 593 d = 594 d = 595 d = 596 d = 597 d = 598 d = 599 d = 600 d = 601 d = 602 d = 603 d = 604 d = 605 d = 606 d = 607 d = 608 d = 609 d = 610 d = 611 d = 612 d = 613 d = 614 d = 615 d = 616 d = 617 d = 618 d = 619 d = 620 d = 621 d = 622 d = 623 d = 624 d = 625 d = 626 d = 627 d = 628 d = 629 d = 630 d = 631 d = 632 d = 633 d = 634 d = 635 d = 636 d = 637 d = 638 d = 639 d = 640 d = 641 d = 642 d = 643 d = 644 d = 645 d = 646 d = 647 d = 648 d = 649 d = 650 d = 651 d = 652 d = 653 d = 654 d = 655 d = 656 d = 657 d = 658 d = 659 d = 660 d = 661 d = 662 d = 663 d = 664 d = 665 d = 666 d = 667 d = 668 d = 669 d = 670 d = 671 d = 672 d = 673 d = 674 d = 675 d = 676 d = 677 d = 678 d = 679 d = 680 d = 681 d = 682 d = 683 d = 684 d = 685 d = 686 d = 687 d = 688 d = 689 d = 690 d = 691 d = 692 d = 693 d = 694 d = 695 d = 696 d = 697 d = 698 d = 699 d = 700 d = 701 d = 702 d = 703 d = 704 d = 705 d = 706 d = 707 d = 708 d = 709 d = 710 d = 711 d = 712 d = 713 d = 714 d = 715 d = ...

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!