Cody

Problem 1683. Create different color vectors.

Solution 2225549

Submitted on 20 Apr 2020
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   Fail
x = 3; y = get_colorVs(x); c0 = 0; c1 = 0; cw = 0; cs = 0; cd = 0; for i = 1:3 cs = cs + (length(y{i})~=3); c0 = c0 + sum(y{i}<0); c1 = c1 + sum(y{i}>1); cw = cw + (sum(y{i}) > 2.5); end for i = 1:x-1 for j = i+1:x cd = cd + (sum(y{i}==y{j}) == 3); end end assert(isequal(cs+c0+c1+cw+cd,0))

y = 1×1 cell array {1×3 double} c1 = 0.3000 c2 = 0.5000 c3 = 0.5000 y = 1×2 cell array {1×3 double} {1×3 double} c1 = 0.4000 c2 = 1.4000 c3 = 0.8000 y = 1×3 cell array {1×3 double} {1×3 double} {1×3 double} c1 = 0.5000 c2 = 2.1000 c3 = 1.5000

Assertion failed.

2   Fail
x = 12; y = get_colorVs(x); c0 = 0; c1 = 0; cw = 0; cs = 0; cd = 0; for i = 1:3 cs = cs + (length(y{i})~=3); c0 = c0 + sum(y{i}<0); c1 = c1 + sum(y{i}>1); cw = cw + (sum(y{i}) > 2.5); end for i = 1:x-1 for j = i+1:x cd = cd + (sum(y{i}==y{j}) == 3); end end assert(isequal(cs+c0+c1+cw+cd,0))

y = 1×1 cell array {1×3 double} c1 = 0.6000 c2 = 0.6000 c3 = 0.9000 y = 1×2 cell array {1×3 double} {1×3 double} c1 = 0.8000 c2 = 1.3000 c3 = 1.1000 y = 1×3 cell array {1×3 double} {1×3 double} {1×3 double} c1 = 1.3000 c2 = 1.9000 c3 = 1.8000 y = 1×4 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 1.6000 c2 = 2.1000 c3 = 1.9000 y = 1×5 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 1.6000 c2 = 2.4000 c3 = 2.6000 y = 1×6 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 1.7000 c2 = 2.7000 c3 = 3.5000 y = 1×7 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 1.8000 c2 = 2.9000 c3 = 4.1000 y = 1×8 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 2.5000 c2 = 3.5000 c3 = 4.5000 y = 1×9 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 2.9000 c2 = 3.7000 c3 = 5.3000 y = 1×10 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 3.2000 c2 = 4.3000 c3 = 5.4000 y = 1×11 cell array {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} c1 = 3.8000 c2 = 4.8000 c3 = 5.9000 y = 1×12 cell array Columns 1 through 11 {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} Column 12 {1×3 double} c1 = 4.7000 c2 = 5.3000 c3 = 6.5000

Assertion failed.

Suggested Problems

More from this Author1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!