This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('sliding3d.m');
assert(isempty(strfind(filetext,'eval')))
assert(isempty(strfind(filetext,'echo')))
|
2 | Pass |
p = [0;2;3;1;5;6;4;7;9;10;11;12;13;17;14;16;8;18;19;20;21;22;23;15;25;26;24];
m = sliding3d(p);
for i = 1:numel(m)
if round(m(i)) == m(i) && m(i) <= numel(p) && m(i) > 0
zero=find(p == 0);
[a0 b0 c0] = ind2sub([3 3 3],zero);
[a1 b1 c1] = ind2sub([3 3 3],m(i));
if abs(a1 - a0) + abs(b1 - b0) + abs(c1 - c0) == 1
p([m(i) zero]) = p([zero m(i)]);
end
end
end
assert(isequal(p,[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;0]))
|
3 | Pass |
p = [1;0;2;4;8;5;7;9;18;10;21;12;11;14;15;16;17;6;13;3;19;20;22;24;25;23;26];
m = sliding3d(p);
for i = 1:numel(m)
if round(m(i)) == m(i) && m(i) <= numel(p) && m(i) > 0
zero=find(p == 0);
[a0 b0 c0] = ind2sub([3 3 3],zero);
[a1 b1 c1] = ind2sub([3 3 3],m(i));
if abs(a1 - a0) + abs(b1 - b0) + abs(c1 - c0) == 1
p([m(i) zero]) = p([zero m(i)]);
end
end
end
assert(isequal(p,[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;0]))
|
4 | Pass |
p = [1;4;3;19;10;6;7;2;9;20;11;0;16;14;12;5;13;18;22;23;21;17;15;24;25;8;26];
m = sliding3d(p);
for i = 1:numel(m)
if round(m(i)) == m(i) && m(i) <= numel(p) && m(i) > 0
zero=find(p == 0);
[a0 b0 c0] = ind2sub([3 3 3],zero);
[a1 b1 c1] = ind2sub([3 3 3],m(i));
if abs(a1 - a0) + abs(b1 - b0) + abs(c1 - c0) == 1
p([m(i) zero]) = p([zero m(i)]);
end
end
end
assert(isequal(p,[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;0]))
|
5 | Pass |
p = [1;5;3;10;7;0;13;9;24;22;2;15;16;11;17;12;8;6;19;20;21;26;14;23;4;25;18];
m = sliding3d(p);
for i = 1:numel(m)
if round(m(i)) == m(i) && m(i) <= numel(p) && m(i) > 0
zero=find(p == 0);
[a0 b0 c0] = ind2sub([3 3 3],zero);
[a1 b1 c1] = ind2sub([3 3 3],m(i));
if abs(a1 - a0) + abs(b1 - b0) + abs(c1 - c0) == 1
p([m(i) zero]) = p([zero m(i)]);
end
end
end
assert(isequal(p,[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;0]))
|
397 Solvers
Omit columns averages from a matrix
482 Solvers
451 Solvers
288 Solvers
213 Solvers