Cody

Solution 1703328

Submitted on 6 Jan 2019 by Nikolaos Nikolaou
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:100; y_correct = false(1,100); y_correct([1 3 6 10 15 21 28 36 45 55 66 78 91]) = true; assert(isequal(isTriangleNumber(x),y_correct))

t = 1 y = logical 1 t = 1.0000 1.0308 y = 1×2 logical array 1 0 t = 1.0000 1.0308 1.0000 y = 1×3 logical array 1 0 1 t = 1.0000 1.0308 1.0000 1.1489 y = 1×4 logical array 1 0 1 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 y = 1×5 logical array 1 0 1 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 y = 1×6 logical array 1 0 1 0 0 1 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 y = 1×7 logical array 1 0 1 0 0 1 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 y = 1×8 logical array 1 0 1 0 0 1 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 y = 1×9 logical array 1 0 1 0 0 1 0 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 y = 1×10 logical array 1 0 1 0 0 1 0 0 0 1 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 y = 1×11 logical array 1 0 1 0 0 1 0 0 0 1 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 y = 1×12 logical array 1 0 1 0 0 1 0 0 0 1 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 y = 1×13 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 y = 1×14 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 y = 1×15 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 y = 1×16 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 y = 1×17 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 t = 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 y = 1×18 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Column 19 1.0308 y = 1×19 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 20 1.0308 1.0574 y = 1×20 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 21 1.0308 1.0574 1.0000 y = 1×21 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 22 1.0308 1.0574 1.0000 1.0234 y = 1×22 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 23 1.0308 1.0574 1.0000 1.0234 1.0463 y = 1×23 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 24 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 y = 1×24 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 25 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 y = 1×25 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 26 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 y = 1×26 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 27 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 y = 1×27 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 28 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 1.0000 y = 1×28 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 29 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 1.0000 1.0176 y = 1×29 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 30 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 1.0000 1.0176 1.0349 y = 1×30 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 31 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 1.0000 1.0176 1.0349 1.0520 y = 1×31 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 32 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 1.0000 1.0176 1.0349 1.0520 1.0020 y = 1×32 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 1.0630 1.0000 1.0325 1.0641 1.0035 Columns 19 through 33 1.0308 1.0574 1.0000 1.0234 1.0463 1.0686 1.0127 1.0326 1.0522 1.0000 1.0176 1.0349 1.0520 1.0020 1.0174 y = 1×33 logical array 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 t = Columns 1 through 18 1.0000 1.0308 1.0000 1.1489 1.0672 1.0000 1.0785 1.0078 1.0680 1.0000 1.0482 1.0943 1.0247 ...

2   Pass
x = 1; y_correct = true; assert(isequal(isTriangleNumber(x),y_correct))

t = 1 y = logical 1 y = logical 1

3   Pass
x = [4912734125;4912734126]; y_correct = [false;true]; assert(isequal(isTriangleNumber(x),y_correct))

t = 1.0000 y = logical 0 t = 1.0000 1.0000 y = 1×2 logical array 0 1 y = 2×1 logical array 0 1