Cody

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

Solution 3032863

Submitted on 2 Oct 2020 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
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

let = 65 66 67 68 age = 13 27 25 5

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

let = 65 66 67 age = 20 30 24

3   Pass
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

let = 65 66 67 68 age = 35 11 42 27

4   Pass
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

let = 65 66 67 age = 34 11 51

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

let = 65 66 67 68 69 age = 10 14 21 33 42

6   Pass
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

let = 65 66 67 68 69 age = 10 14 21 33 42

7   Pass
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

let = 65 66 67 68 69 age = 30 15 27 13 47

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

let = 65 66 67 age = 20 30 24

9   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 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

let = 65 66 67 68 69 age = 30 15 27 13 47

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

let = 65 66 67 68 age = 13 27 25 5

### Community Treasure Hunt

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

Start Hunting!