Cody

Solution 1902313

Submitted on 16 Aug 2019 by Andreas Neul
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
n = 3; y_correct = 15; assert(isequal(magic_sum(n),y_correct))

x = 8 1 6 m = 15

2   Pass
n = 5; y_correct = 65; assert(isequal(magic_sum(n),y_correct))

x = 17 24 1 8 15 m = 65

3   Pass
n = 7; y_correct = 175; assert(isequal(magic_sum(n),y_correct))

x = 30 39 48 1 10 19 28 m = 175

4   Pass
n = 8; y_correct = 260; assert(isequal(magic_sum(n),y_correct))

x = 64 2 3 61 60 6 7 57 m = 260

5   Pass
n = 20; y_correct = 4010; assert(isequal(magic_sum(n),y_correct))

x = 400 2 3 397 396 6 7 393 392 10 11 389 388 14 15 385 384 18 19 381 m = 4010

6   Pass
n = 100; y_correct = 500050; assert(isequal(magic_sum(n),y_correct))

x = Columns 1 through 14 10000 2 3 9997 9996 6 7 9993 9992 10 11 9989 9988 14 Columns 15 through 28 15 9985 9984 18 19 9981 9980 22 23 9977 9976 26 27 9973 Columns 29 through 42 9972 30 31 9969 9968 34 35 9965 9964 38 39 9961 9960 42 Columns 43 through 56 43 9957 9956 46 47 9953 9952 50 51 9949 9948 54 55 9945 Columns 57 through 70 9944 58 59 9941 9940 62 63 9937 9936 66 67 9933 9932 70 Columns 71 through 84 71 9929 9928 74 75 9925 9924 78 79 9921 9920 82 83 9917 Columns 85 through 98 9916 86 87 9913 9912 90 91 9909 9908 94 95 9905 9904 98 Columns 99 through 100 99 9901 m = 500050

7   Pass
n = 200; y_correct = 4000100; assert(isequal(magic_sum(n),y_correct))

x = Columns 1 through 14 40000 2 3 39997 39996 6 7 39993 39992 10 11 39989 39988 14 Columns 15 through 28 15 39985 39984 18 19 39981 39980 22 23 39977 39976 26 27 39973 Columns 29 through 42 39972 30 31 39969 39968 34 35 39965 39964 38 39 39961 39960 42 Columns 43 through 56 43 39957 39956 46 47 39953 39952 50 51 39949 39948 54 55 39945 Columns 57 through 70 39944 58 59 39941 39940 62 63 39937 39936 66 67 39933 39932 70 Columns 71 through 84 71 39929 39928 74 75 39925 39924 78 79 39921 39920 82 83 39917 Columns 85 through 98 39916 86 87 39913 39912 90 91 39909 39908 94 95 39905 39904 98 Columns 99 through 112 99 39901 39900 102 103 39897 39896 106 107 39893 39892 110 111 39889 Columns 113 through 126 39888 114 115 39885 39884 118 119 39881 39880 122 123 39877 39876 126 Columns 127 through 140 127 39873 39872 130 131 39869 39868 134 135 39865 39864 138 139 39861 Columns 141 through 154 39860 142 143 39857 39856 146 147 39853 39852 150 151 39849 39848 154 Columns 155 through 168 155 39845 39844 158 159 39841 39840 162 163 39837 39836 166 167 39833 Columns 169 through 182 39832 170 171 39829 39828 174 175 39825 39824 178 179 39821 39820 182 Columns 183 through 196 183 39817 39816 186 187 39813 39812 190 191 39809 39808 194 195 39805 Columns 197 through 200 39804 198 199 39801 m = 4000100

8   Pass
n = 1000; y_correct = 500000500; assert(isequal(magic_sum(n),y_correct))

x = Columns 1 through 14 1000000 2 3 999997 999996 6 7 999993 999992 10 11 999989 999988 14 Columns 15 through 28 15 999985 999984 18 19 999981 999980 22 23 999977 999976 26 27 999973 Columns 29 through 42 999972 30 31 999969 999968 34 35 999965 999964 38 39 999961 999960 42 Columns 43 through 56 43 999957 999956 46 47 999953 999952 50 51 999949 999948 54 55 999945 Columns 57 through 70 999944 58 59 999941 999940 62 63 999937 999936 66 67 999933 999932 70 Columns 71 through 84 71 999929 999928 74 75 999925 999924 78 79 999921 999920 82 83 999917 Columns 85 through 98 999916 86 87 999913 999912 90 91 999909 999908 94 95 999905 999904 98 Columns 99 through 112 99 999901 999900 102 103 999897 999896 106 107 999893 999892 110 111 999889 Columns 113 through 126 999888 114 115 999885 999884 118 119 999881 999880 122 123 999877 999876 126 Columns 127 through 140 127 999873 999872 130 131 999869 999868 134 135 999865 999864 138 139 999861 Columns 141 through 154 999860 142 143 999857 999856 146 147 999853 999852 150 151 999849 999848 154 Columns 155 through 168 155 999845 999844 158 159 999841 999840 162 163 999837 999836 166 167 999833 Columns 169 through 182 999832 170 171 999829 999828 174 175 999825 999824 178 179 999821 999820 182 Columns 183 through 196 183 999817 999816 186 187 999813 999812 190 191 999809 999808 194 195 999805 Columns 197 through 210 999804 198 199 999801 999800 202 203 999797 999796 206 207 999793 999792 210 Columns 211 through 224 211 999789 999788 214 215 999785 999784 218 219 999781 999780 222 223 999777 Columns 225 through 238 999776 226 227 999773 999772 230 231 999769 999768 234 235 999765 999764 238 Columns 239 through 252 239 999761 999760 242 243 999757 999756 246 247 999753 999752 250 251 999749 Columns 253 through 266 999748 254 255 999745 999744 258 259 999741 999740 262 263 999737 999736 266 Columns 267 through 280 267 999733 999732 270 271 999729 999728 274 275 999725 999724 278 279 999721 Columns 281 through 294 999720 282 283 999717 999716 286 287 999713 999712 290 291 999709 999708 294 Columns 295 through 308 295 999705 999704 298 299 999701 999700 302 303 999697 999696 306 307 999693 Columns 309 through 322 999692 310 311 999689 999688 314 315 999685 999684 318 319 999681 999680 322 Columns 323 through 336 323 999677 999676 326 327 999673 999672 330 331 999669 999668 334 335 999665 Columns 337 through 350 999664 338 339 999661 999660 342 343 999657 999656 346 347 999653 999652 350 Columns 351 through 364 351 999649 999648 354 355 999645 999644 358 359 999641 999640 362 363 999637 Columns 365 through 378 999636 366 367 999633 999632 370 371 999629 999628 374 375 999625 999624 378 Columns 379 through 392 379 999621 999620 382 383 999617 999616 386 387 999613 999612 390 391 999609 Columns 393 through 406 999608 394 395 999605 999604 398 399 999601 999600 402 403 999597 999596 406 Columns 407 through 420 407 999593 999592 410 411 999589 999588 414 415 999585 999584 418 419 999581 Columns 421 through 434 999580 422 423 999577 999576 426 427 999573 999572 430 431 999569 999568 434 Columns 435 through 448 435 999565 999564 438 439 999561 999560 442 443 999557 999556 446 447 999553 Columns 449 through 462 999552 450 451 999549 999548 454 455 999545 999544 458 459 999541 999540 462 Columns 463 through 476 463 999537 999536 466 467 999533 999532 470 471 999529 999528 474 475 999525 Columns 477 through 490 999524 478 479 999521 999520 482 483 999517 999516 486 487 999513 999512 490 Columns 491 through 504 491 999509 999508 494 495 999505 999504 498 499 999501 999500 502 503 999497 Columns 505 through 518 999496 506 507 999493 999492 510 511 999489 999488 514 515 999485 999484 518 Columns 519 through 532 519 999481 999480 522 523 999477 999476 526 527 999473 999472 530 531 999469 Columns 533 through 546 999468 534 535 999465 999464 538 539 999461 999460 542 543 999457 999456 546 Columns 547 through 560 547 999453 999452 550 551 999449 999448 554 555 999445 999444 558 559 999441 Columns 561 through 574 999440 562 563 999437 999436 566 567 999433 999432 570 571 999429 999428 574 Columns 575 through 588 575 999425 999424 578 579 999421 999420 582 583 999417 999416 586 587 999413 Columns 589 through 602 999412 590 591 999409 999408 594 595 999405 999404 598 599 999401 999400 602 Columns 603 through 616 603 999397 999396 606 607 999393 999392 610 611 999389 999388 614 615 999385 Columns 617 through 630 999384 618 619 999381 999380 622 623 999377 999376 626 627 999373 999372 630 Columns 631 through 644 631 999369 999368 634 635 999365 999364 638 639 999361 999360 642 643 999357 Columns 645 through 658 999356 646 647 999353 999352 650 651 999349 999348 654 655 999345 999344 658 Columns 659 through 672 659 999341 999340 662 663 999337 999336 666 667 999333 999332 670 671 999329 Columns 673 through 686 999328 674 675 999325 999324 678 679 999321 999320 682 683 999317 999316 686 Columns 687 through 700 687 999313 999312 690 691 999309 999308 694 695 999305 999304 698 699 999301 Columns 701 through 714 999300 702 703 999297 999296 706 707 999293 999292 710 711 ...