Cody

Solution 1962357

Submitted on 6 Oct 2019 by Augusto Mazzei
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
x = [1 0 0 2 0]; y_correct = [1 1 1 2 2]; assert(isequal(bleed_to_the_right(x),y_correct)) filetext = fileread('bleed_to_the_right.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp* command is forbidden') assert(isempty(strfind(filetext, 'eval')),'eval* command is forbidden') assert(isempty(strfind(filetext, 'inline')),'inline command is forbidden')

zz = 1×5 logical array 1 0 0 1 0 d = 1 4 w = 1 2 ans = 1 1 1 2 2

2   Pass
x = [0 0 -12 13 0 i 0 -i 76.54321 0 0]; y_correct = [0 0 -12 13 13 i i -i 76.54321 76.54321 76.54321]; assert(isequal(bleed_to_the_right(x),y_correct))

zz = 1×11 logical array 0 0 1 1 0 1 0 1 1 0 0 d = 3 4 6 8 9 w = -12.0000 + 0.0000i 13.0000 + 0.0000i 0.0000 + 1.0000i 0.0000 - 1.0000i 76.5432 + 0.0000i ans = Columns 1 through 9 0.0000 + 0.0000i 0.0000 + 0.0000i -12.0000 + 0.0000i 13.0000 + 0.0000i 13.0000 + 0.0000i 0.0000 + 1.0000i 0.0000 + 1.0000i 0.0000 - 1.0000i 76.5432 + 0.0000i Columns 10 through 11 76.5432 + 0.0000i 76.5432 + 0.0000i

3   Pass
x = [1:100 0]; y_correct = [1:100 100]; assert(isequal(bleed_to_the_right(x),y_correct))

zz = 1×101 logical array Columns 1 through 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 46 through 90 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 91 through 101 1 1 1 1 1 1 1 1 1 1 0 d = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 60 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Columns 61 through 90 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Columns 91 through 100 91 92 93 94 95 96 97 98 99 100 w = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 60 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Columns 61 through 90 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Columns 91 through 100 91 92 93 94 95 96 97 98 99 100 ans = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 60 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Columns 61 through 90 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Columns 91 through 101 91 92 93 94 95 96 97 98 99 100 100

4   Pass
x = rand(1,1000); x(randi(500,1,50)*2) = 0; y_correct = x; y_correct(~y_correct) = y_correct(find(~y_correct)-1); assert(isequal(bleed_to_the_right(x),y_correct))

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

5   Pass
x = sqrt(1:100); y_correct = floor(x); x(x~=floor(x)) = 0; assert(isequal(bleed_to_the_right(x),y_correct))

zz = 1×100 logical array Columns 1 through 45 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Columns 46 through 90 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Columns 91 through 100 0 0 0 0 0 0 0 0 0 1 d = 1 4 9 16 25 36 49 64 81 100 w = 1 2 3 4 5 6 7 8 9 10 ans = Columns 1 through 30 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 Columns 31 through 60 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 Columns 61 through 90 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 Columns 91 through 100 9 9 9 9 9 9 9 9 9 10