Cody

Solution 1687386

Submitted on 6 Dec 2018
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
filetext = fileread('sliding3d.m'); assert(isempty(strfind(filetext,'eval'))) assert(isempty(strfind(filetext,'echo')))

Assertion failed.

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]))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In sliding3d (line 2) In ScoringEngineTestPoint2 (line 2) In solutionTest (line 5)]

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]))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In sliding3d (line 2) In ScoringEngineTestPoint3 (line 2) In solutionTest (line 7)]

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]))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In sliding3d (line 2) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)]

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]))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In sliding3d (line 2) In ScoringEngineTestPoint5 (line 2) In solutionTest (line 11)]