Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x1 = [0 1]; x2 = [0 1]; x3 = [0 1];
y_correct = [0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1];
assert(isequal(myfullfact(x1,x2,x3),y_correct))
|
2 | Pass |
x1 = [0 1]; x2 = [-1]; x3 = [-1 0 1];
y_correct = [0 -1 -1
0 -1 0
0 -1 1
1 -1 -1
1 -1 0
1 -1 1];
assert(isequal(myfullfact(x1,x2,x3),y_correct))
|
3 | Pass |
x1 = 0; x2 = 2; x3 = 4; x4 = 8; x5 = 7; x6 = 6; x7 = 4; x8 = 1; x9 = 1; x10 = 0;
y_correct = [x1 x2 x3 x4 x5 x6 x7 x8 x9 x10];
assert(isequal(myfullfact(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10),y_correct))
|
4 | Pass |
x1 = 'ab'; x2 = 'cde';
y_correct = ['ac'
'ad'
'ae'
'bc'
'bd'
'be'];
assert(isequal(myfullfact(x1,x2),y_correct))
|
5 | Pass |
x1 = 'a'; x2 = 'a'; x3 = 'z';
y_correct = 'aaz';
assert(isequal(myfullfact(x1,x2,x3),y_correct))
|
6 | Pass |
x1 = '!@#'; x2 = '23';
y_correct = ['!2'
'!3'
'@2'
'@3'
'#2'
'#3'];
assert(isequal(myfullfact(x1,x2),y_correct))
|
7 | Pass |
x1 = '@#'; x2 = 'm'; x3 = 'a'; x4 = 't'; x5 = 'l'; x6 = 'a'; x7 = 'b'; x8 = '$%*';
y_correct = ['@matlab$'
'@matlab%'
'@matlab*'
'#matlab$'
'#matlab%'
'#matlab*'];
assert(isequal(myfullfact(x1,x2,x3,x4,x5,x6,x7,x8),y_correct))
|
8 | Pass |
% A manual implementation used to validate other solutions. Please be advised that generalization of this is straightforward but inefficient in terms of Cody size. To get a solution with possibly smaller size, try different ideas please.
for iter = 1:20
a = randi(10,5,1);
x = arrayfun(@(x)(1:x).',a,'un',0);
[x1,x2,x3,x4,x5] = deal(x{:});
y1 = repelem(x1, prod(a(2:5)), 1);
y2 = repmat(repelem(x2, prod(a(3:5)), 1), a(1), 1);
y3 = repmat(repelem(x3, prod(a(4:5)), 1), prod(a(1:2)), 1);
y4 = repmat(repelem(x4, a(5), 1), prod(a(1:3)), 1);
y5 = repmat(x5, prod(a(1:4)), 1);
y_correct = [y1, y2, y3, y4, y5];
assert(isequal(myfullfact(x1,x2,x3,x4,x5),y_correct));
end
|
131 Solvers
746 Solvers
Flag largest magnitude swings as they occur
582 Solvers
420 Solvers
56 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!