Cody

Problem 42385. Combined Ages 4 - Non-symmetric with multiples, n ≥ 3

Solution 3388253

Submitted on 26 Oct 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   Pass
ABCD = 70; ABC = 65; AB = 40; BC = 52; y = combined_ages_nonsymmetric_w_mult(ABCD,ABC,AB,BC); y_correct = [13;27;25;5]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

2   Pass
ABCC = 98; BBC = 84; AAB = 70; y = combined_ages_nonsymmetric_w_mult(ABCC,BBC,AAB); y_correct = [20;30;24]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

3   Fail
ABCDA = 150; ABCB = 99; BCDB = 91; ABDAD = 135; y = combined_ages_nonsymmetric_w_mult(ABCDA,ABCB,BCDB,ABDAD); y_correct = [35;11;42;27]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-4. Error in combined_ages_nonsymmetric_w_mult (line 10) mat(k,n(1):n(end)) = histc(n, uv); Error in Test3 (line 5) y = combined_ages_nonsymmetric_w_mult(ABCDA,ABCB,BCDB,ABDAD);

4   Fail
ABBA = 90; BCC = 113; ABCBA = 141; y = combined_ages_nonsymmetric_w_mult(ABBA,BCC,ABCBA); y_correct = [34;11;51]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-2. Error in combined_ages_nonsymmetric_w_mult (line 10) mat(k,n(1):n(end)) = histc(n, uv); Error in Test4 (line 4) y = combined_ages_nonsymmetric_w_mult(ABBA,BCC,ABCBA);

5   Pass
ABCDE = 120; ABCDD = 111; ABCCC = 87; ABBBB = 66; AAAAA = 50; y = combined_ages_nonsymmetric_w_mult(ABCDE,ABCDD,ABCCC,ABBBB,AAAAA); y_correct = [10,14,21,33,42]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

6   Fail
ABC = 45; BEA = 66; CAE = 73; DAB = 57; AAD = 53; y = combined_ages_nonsymmetric_w_mult(ABC,BEA,CAE,DAB,AAD); y_correct = [10,14,21,33,42]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

Unable to perform assignment because the size of the left side is 1-by-0 and the size of the right side is 1-by-3. Error in combined_ages_nonsymmetric_w_mult (line 10) mat(k,n(1):n(end)) = histc(n, uv); Error in Test6 (line 6) y = combined_ages_nonsymmetric_w_mult(ABC,BEA,CAE,DAB,AAD);

7   Fail
ABCABC = 144; BEAB = 107; CAEAD = 147; DABB = 73; AADAA = 133; y = combined_ages_nonsymmetric_w_mult(ABCABC,BEAB,CAEAD,DABB,AADAA); y_correct = [30,15,27,13,47]; for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-3. Error in combined_ages_nonsymmetric_w_mult (line 10) mat(k,n(1):n(end)) = histc(n, uv); Error in Test7 (line 6) y = combined_ages_nonsymmetric_w_mult(ABCABC,BEAB,CAEAD,DABB,AADAA);

8   Pass
ind = randi(4); switch ind case 1 ABCC = 98; BBC = 84; AAB = 70; y = combined_ages_nonsymmetric_w_mult(ABCC,BBC,AAB); y_correct = [20;30;24]; case 2 ABCDA = 150; ABCB = 99; BCDB = 91; ABDAD = 135; y = combined_ages_nonsymmetric_w_mult(ABCDA,ABCB,BCDB,ABDAD); y_correct = [35;11;42;27]; case 3 ABCABC = 144; BEAB = 107; CAEAD = 147; DABB = 73; AADAA = 133; y = combined_ages_nonsymmetric_w_mult(ABCABC,BEAB,CAEAD,DABB,AADAA); y_correct = [30,15,27,13,47]; case 4 ABCD = 70; ABC = 65; AB = 40; BC = 52; y = combined_ages_nonsymmetric_w_mult(ABCD,ABC,AB,BC); y_correct = [13;27;25;5]; end for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

9   Fail
ind = randi(4); switch ind case 1 ABCC = 98; BBC = 84; AAB = 70; y = combined_ages_nonsymmetric_w_mult(ABCC,BBC,AAB); y_correct = [20;30;24]; case 2 ABCABC = 144; BEAB = 107; CAEAD = 147; DABB = 73; AADAA = 133; y = combined_ages_nonsymmetric_w_mult(ABCABC,BEAB,CAEAD,DABB,AADAA); y_correct = [30,15,27,13,47]; case 3 ABCD = 70; ABC = 65; AB = 40; BC = 52; y = combined_ages_nonsymmetric_w_mult(ABCD,ABC,AB,BC); y_correct = [13;27;25;5]; case 4 ABC = 45; BEA = 66; CAE = 73; DAB = 57; AAD = 53; y = combined_ages_nonsymmetric_w_mult(ABC,BEA,CAE,DAB,AAD); y_correct = [10,14,21,33,42]; end for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

Unable to perform assignment because the size of the left side is 1-by-0 and the size of the right side is 1-by-3. Error in combined_ages_nonsymmetric_w_mult (line 10) mat(k,n(1):n(end)) = histc(n, uv); Error in Test9 (line 30) y = combined_ages_nonsymmetric_w_mult(ABC,BEA,CAE,DAB,AAD);

10   Pass
ind = randi(4); switch ind case 1 ABBA = 90; BCC = 113; ABCBA = 141; y = combined_ages_nonsymmetric_w_mult(ABBA,BCC,ABCBA); y_correct = [34;11;51]; case 2 ABCD = 70; ABC = 65; AB = 40; BC = 52; y = combined_ages_nonsymmetric_w_mult(ABCD,ABC,AB,BC); y_correct = [13;27;25;5]; case 3 ABCDA = 150; ABCB = 99; BCDB = 91; ABDAD = 135; y = combined_ages_nonsymmetric_w_mult(ABCDA,ABCB,BCDB,ABDAD); y_correct = [35;11;42;27]; case 4 ABCC = 98; BBC = 84; AAB = 70; y = combined_ages_nonsymmetric_w_mult(ABCC,BBC,AAB); y_correct = [20;30;24]; end for i = 1:numel(y_correct) assert(isequal(y(i),y_correct(i))) end

Suggested Problems

More from this Author139

Community Treasure Hunt

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

Start Hunting!