Cody

Solution 298940

Submitted on 9 Aug 2013 by Alfonso Nieto-Castanon
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
%% % Load function rubik_rot.m tic urlwrite('http://tinyurl.com/matlab-rubik-rot','rubik_rot.m') ; rehash path toc
[Warning: Function /opt/mlsedu/mdcsserver/latest/m/web_common/shadow/license.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/home.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/keyboard.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/more.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/pause.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/simulink.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] Elapsed time is 0.072395 seconds.
2   Pass
%% % For mov=1 solution is 7. Need U' to solve U in 1 move % mov=1; % U answer should be 7 % Solved Cube Vector r=[0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5]; r1=rubik_rot(1,r); % Create Challenge Cube mov_vec=rubik_solve(r1); for i=1:length(mov_vec) % Perform moves to see if it solves r1=rubik_rot(mov_vec(i),r1); end assert(isequal(length(mov_vec),1), [sprintf('Exp_moves=1 Exp Mov=7 moves=[') sprintf('%i ',mov_vec(:)) sprintf(']\n')]) assert(isequal(r1,r),sprintf('Exp Mov=7 moves=[%i %i]\n',mov_vec(:)))
y = 7
3   Pass
%% % For mov=14 the solution is 14. Need F2 to solve F2 in 1 move % Solved Cube Vector r=[0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5]; r1=rubik_rot(14,r); % Create Challenge Cube mov_vec=rubik_solve(r1); for i=1:length(mov_vec) % Perform moves to see if it solves r1=rubik_rot(mov_vec(i),r1); end assert(isequal(length(mov_vec),1), [sprintf('Exp_moves=1 Exp Mov=14 moves=[') sprintf('%i ',mov_vec(:)) sprintf(']\n')]) assert(isequal(r1,r),sprintf('Exp Mov=14 move=[%i]\n',mov_vec(:)))
y = 14
4   Pass
%% % Starting Cube Vector r=[0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5]; r1=rubik_rot(2,r); % Create Challenge Cube, First Twist r1=rubik_rot(9,r1); % Create Challenge Cube, Second Twist mov_vec=rubik_solve(r1); for i=1:length(mov_vec) % Perform moves to see if it solves r1=rubik_rot(mov_vec(i),r1); end assert(isequal(length(mov_vec),2), [sprintf('Exp_moves=2 Exp Mov=[3 8] moves=[') sprintf('%i ',mov_vec(:)) sprintf(']\n')]) assert(isequal(r1,r),sprintf('Exp Mov=[3 8] moves=[%i %i]\n',mov_vec(:)))
y = 3 8
5   Pass
%% % Anti-Hard code solution Test Case #1 cmov=[7:12 1:6 13:18]; % Complementary Move % Starting Cube Vector r=[0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5]; move_map=[ 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18; 1 3 4 5 6 7 9 10 11 12 13 15 16 17 18; 1 2 4 5 6 7 8 10 11 12 13 14 16 17 18; 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18; 1 2 3 4 6 7 8 9 10 12 13 14 15 16 18; 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 ; 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18; 1 3 4 5 6 7 9 10 11 12 13 15 16 17 18; 1 2 4 5 6 7 8 10 11 12 13 14 16 17 18; 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18; 1 2 3 4 6 7 8 9 10 12 13 14 15 16 18; 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 ; 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18; 1 3 4 5 6 7 9 10 11 12 13 15 16 17 18; 1 2 4 5 6 7 8 10 11 12 13 14 16 17 18; 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18; 1 2 3 4 6 7 8 9 10 12 13 14 15 16 18; 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 ]; movt1=randi(18); movt2=move_map(movt1,randi(15));% Avoid complementary moves r1=rubik_rot(movt1,r); % Create Challenge Cube: First Turn r1=rubik_rot(movt2,r1); % Create Challenge Cube: Second Turn mov_vec=rubik_solve(r1); for i=1:length(mov_vec) % Perform moves to see if it solves r1=rubik_rot(mov_vec(i),r1); end assert(isequal(length(mov_vec),2), [sprintf('Exp_moves=2 Exp Mov=[%i %i] moves=[',cmov(movt2),cmov(movt1)) sprintf('%i ',mov_vec(:)) sprintf(']\n')]) assert(isequal(r1,r),sprintf('Exp Mov=[%i %i] moves=[%i %i]\n',cmov(movt2),cmov(movt1),mov_vec(:)))
y = 17 18
6   Pass
%% % Anti-Hard code solution Test Case #2 cmov=[7:12 1:6 13:18]; % Complementary Move % Starting Cube Vector r=[0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5]; move_map=[ 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18; 1 3 4 5 6 7 9 10 11 12 13 15 16 17 18; 1 2 4 5 6 7 8 10 11 12 13 14 16 17 18; 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18; 1 2 3 4 6 7 8 9 10 12 13 14 15 16 18; 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 ; 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18; 1 3 4 5 6 7 9 10 11 12 13 15 16 17 18; 1 2 4 5 6 7 8 10 11 12 13 14 16 17 18; 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18; 1 2 3 4 6 7 8 9 10 12 13 14 15 16 18; 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 ; 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18; 1 3 4 5 6 7 9 10 11 12 13 15 16 17 18; 1 2 4 5 6 7 8 10 11 12 13 14 16 17 18; 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18; 1 2 3 4 6 7 8 9 10 12 13 14 15 16 18; 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 ]; mov2t1=randi(18); mov2t2=move_map(mov2t1,randi(15));% Avoid complementary moves r1=rubik_rot(mov2t1,r); % Create Challenge Cube: First Turn r1=rubik_rot(mov2t2,r1); % Create Challenge Cube: Second Turn mov_vec=rubik_solve(r1); for i=1:length(mov_vec) % Perform moves to see if it solves r1=rubik_rot(mov_vec(i),r1); end assert(isequal(length(mov_vec),2), [sprintf('Exp_moves=2 Exp Mov=[%i %i] moves=[',cmov(mov2t2),cmov(mov2t1)) sprintf('%i ',mov_vec(:)) sprintf(']\n')]) assert(isequal(r1,r),sprintf('Exp Mov=[%i %i] moves=[%i %i]\n',cmov(mov2t2),cmov(mov2t1),mov_vec(:)))
y = 18 9