Cody

Solution 129378

Submitted on 21 Aug 2012 by Richard Zapor
  • Size: 5
  • This is the leading solution.
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 max score of 50 seconds feval(@assignin,'caller','score',50)
2   Pass
%% global vf gPass Pass=1; % Load rot map 18 moves : ufdlbru'f'd'l'b'r'u2f2d2l2b2r2 vf=[ 17 2 3 20 5 22 7 8 11 13 16 10 15 9 12 14 41 18 19 44 21 46 23 24 25 26 27 28 29 30 31 32 33 34 6 36 4 38 39 1 40 42 43 37 45 35 47 48; 1 2 3 4 5 25 28 30 9 10 8 12 7 14 15 6 19 21 24 18 23 17 20 22 43 26 27 42 29 41 31 32 33 34 35 36 37 38 39 40 11 13 16 44 45 46 47 48 ; 1 2 38 4 36 6 7 33 9 10 11 12 13 14 15 16 17 18 3 20 5 22 23 8 27 29 32 26 31 25 28 30 48 34 35 45 37 43 39 40 41 42 19 44 21 46 47 24 ; 3 5 8 2 7 1 4 6 33 34 35 12 13 14 15 16 9 10 11 20 21 22 23 24 17 18 19 28 29 30 31 32 25 26 27 36 37 38 39 40 41 42 43 44 45 46 47 48 ; 14 12 9 4 5 6 7 8 46 10 11 47 13 48 15 16 17 18 19 20 21 22 23 24 25 26 1 28 2 30 31 3 35 37 40 34 39 33 36 38 41 42 43 44 45 32 29 27 ; 1 2 3 4 5 6 7 8 9 10 11 12 13 22 23 24 17 18 19 20 21 30 31 32 25 26 27 28 29 38 39 40 33 34 35 36 37 14 15 16 43 45 48 42 47 41 44 46 ; 40 2 3 37 5 35 7 8 14 12 9 15 10 16 13 11 1 18 19 4 21 6 23 24 25 26 27 28 29 30 31 32 33 34 46 36 44 38 39 41 17 42 43 20 45 22 47 48 ; 1 2 3 4 5 16 13 11 9 10 41 12 42 14 15 43 22 20 17 23 18 24 21 19 6 26 27 7 29 8 31 32 33 34 35 36 37 38 39 40 30 28 25 44 45 46 47 48 ; 1 2 19 4 21 6 7 24 9 10 11 12 13 14 15 16 17 18 43 20 45 22 23 48 30 28 25 31 26 32 29 27 8 34 35 5 37 3 39 40 41 42 38 44 36 46 47 33 ; 6 4 1 7 2 8 5 3 17 18 19 12 13 14 15 16 25 26 27 20 21 22 23 24 33 34 35 28 29 30 31 32 9 10 11 36 37 38 39 40 41 42 43 44 45 46 47 48 ; 27 29 32 4 5 6 7 8 3 10 11 2 13 1 15 16 17 18 19 20 21 22 23 24 25 26 48 28 47 30 31 46 38 36 33 39 34 40 37 35 41 42 43 44 45 9 12 14 ; 1 2 3 4 5 6 7 8 9 10 11 12 13 38 39 40 17 18 19 20 21 14 15 16 25 26 27 28 29 22 23 24 33 34 35 36 37 30 31 32 46 44 41 47 42 48 45 43 ; 41 2 3 44 5 46 7 8 16 15 14 13 12 11 10 9 40 18 19 37 21 35 23 24 25 26 27 28 29 30 31 32 33 34 22 36 20 38 39 17 1 42 43 4 45 6 47 48 ; 1 2 3 4 5 43 42 41 9 10 30 12 28 14 15 25 24 23 22 21 20 19 18 17 16 26 27 13 29 11 31 32 33 34 35 36 37 38 39 40 8 7 6 44 45 46 47 48 ; 1 2 43 4 45 6 7 48 9 10 11 12 13 14 15 16 17 18 38 20 36 22 23 33 32 31 30 29 28 27 26 25 24 34 35 21 37 19 39 40 41 42 3 44 5 46 47 8 ; 8 7 6 5 4 3 2 1 25 26 27 12 13 14 15 16 33 34 35 20 21 22 23 24 9 10 11 28 29 30 31 32 17 18 19 36 37 38 39 40 41 42 43 44 45 46 47 48 ; 48 47 46 4 5 6 7 8 32 10 11 29 13 27 15 16 17 18 19 20 21 22 23 24 25 26 14 28 12 30 31 9 40 39 38 37 36 35 34 33 41 42 43 44 45 3 2 1 ; 1 2 3 4 5 6 7 8 9 10 11 12 13 30 31 32 17 18 19 20 21 38 39 40 25 26 27 28 29 14 15 16 33 34 35 36 37 22 23 24 48 47 46 45 44 43 42 41 ]; r=ones(1,48,'uint8'); r(1:8)=0; %5; %Left % straight numeric mapping r(9:16)=1; %2; %Up r(17:24)=2; %3; %Front r(25:32)=3; %4; %Down r(33:40)=4; %6; %Back r(41:48)=5; %7; %Right mix=10; rmov=randi(18,[mix,1]); for i=1:length(rmov) if i>1 % Eliminate move undos % f2 f2 or f f' or f' f if (rmov(i)>12 && rmov(i-1)==rmov(i))||(rmov(i-1)<7 && rmov(i)==rmov(i-1)+6)||... (rmov(i-1)>6 && rmov(i)==rmov(i-1)-6) rmov(i)=rmov(i)+1; % 1:17 map to 2:18 18 map to 1 if rmov(i)==19,rmov(i)=1;end end end r=r(vf(rmov(i),:)); end %assert(isequal(your_fcn_name(x),y_correct)) t0=clock; solv_vec=Rubik_Solve_10(r) dt=etime(clock,t0) % Dubious Code Check if all(r(1:8)==r(1)) && all(r(9:16)==r(9)) && all(r(17:24)==r(17)) && ... all(r(25:32)==r(25)) && all(r(33:40)==r(33)) && all(r(41:48)==r(41)) Pass=0; end Pass=Pass && length(solv_vec<11); length(solv_vec) rt=r; for i=1:length(solv_vec) rt=rt(vf(solv_vec(i),:)); end if all(rt(1:8)==rt(1)) && all(rt(9:16)==rt(9)) && all(rt(17:24)==rt(17)) && ... all(rt(25:32)==rt(25)) && all(rt(33:40)==rt(33)) && all(rt(41:48)==rt(41)) fprintf('Cube Solved\n') Pass=Pass; % No change to Pass status else fprintf('Cube Solve Failure\n') Pass=0; end assert(isequal(Pass,1)) gPass=Pass;
Enter Setup L=2 New Start= 2 New End=19 New Points=270 L=3 New Start= 20 New End=262 New Points=3645 L=4 New Start= 263 New End=3502 New Points=48600 L=5 New Start= 3503 New End=46741 New Points=648585 size(ca) = 621649 48 size(c) = 621649 48 Elapsed time is 4.151923 seconds. solv_vec= 2 17 12 3 11 3 7 6 17 3 solv_vec = 2 17 12 3 11 3 7 6 17 3 dt = 7.5861 ans = 10 Cube Solved
3   Pass
%% global gPass vf Pass1=gPass; r=ones(1,48,'uint8'); r(1:8)=0; %5; %Left % straight numeric mapping r(9:16)=1; %2; %Up r(17:24)=2; %3; %Front r(25:32)=3; %4; %Down r(33:40)=4; %6; %Back r(41:48)=5; %7; %Right rbase=r; sum_dt=0; for cases=1:10 r=rbase; mix=10; rmov=randi(18,[mix,1]); for i=1:length(rmov) if i>1 % Eliminate move undos % f2 f2 or f f' or f' f if (rmov(i)>12 && rmov(i-1)==rmov(i))||(rmov(i-1)<7 && rmov(i)==rmov(i- 1)+6)||... (rmov(i-1)>6 && rmov(i)==rmov(i-1)-6) rmov(i)=rmov(i)+1; % 1:17 map to 2:18 18 map to 1 if rmov(i)==19,rmov(i)=1;end end end r=r(vf(rmov(i),:)); end t0=clock; solv_vec=Rubik_Solve_10(r) dt=etime(clock,t0) sum_dt=sum_dt+dt; Pass1=Pass1 && length(solv_vec<11); rt=r; for i=1:length(solv_vec) rt=rt(vf(solv_vec(i),:)); end if all(rt(1:8)==rt(1)) && all(rt(9:16)==rt(9)) && all(rt(17:24)==rt(17)) && ... all(rt(25:32)==rt(25)) && all(rt(33:40)==rt(33)) && all(rt(41:48)==rt(41)) fprintf('Cube Solved\n') Pass1=Pass1; % No change to Pass1 status else fprintf('Cube Solve Failure\n') Pass1=0; end end assert(isequal(Pass1,1)) if Pass1 feval(@assignin,'caller','score',floor(sum_dt)) end
Elapsed time is 0.543154 seconds. solv_vec= 10 18 9 18 7 13 17 15 5 13 solv_vec = 10 18 9 18 7 13 17 15 5 13 dt = 0.5436 Cube Solved Elapsed time is 0.511825 seconds. solv_vec= 16 15 14 3 2 17 15 7 18 7 solv_vec = 16 15 14 3 2 17 15 7 18 7 dt = 0.5122 Cube Solved Elapsed time is 0.527745 seconds. solv_vec= 13 8 7 9 7 18 3 12 1 solv_vec = 13 8 7 9 7 18 3 12 1 dt = 0.5281 Cube Solved Elapsed time is 0.498208 seconds. solv_vec= 7 15 6 5 10 12 14 7 18 1 solv_vec = 7 15 6 5 10 12 14 7 18 1 dt = 0.4986 Cube Solved Elapsed time is 0.510560 seconds. solv_vec= 4 7 6 10 9 15 11 4 12 17 solv_vec = 4 7 6 10 9 15 11 4 12 17 dt = 0.5110 Cube Solved Elapsed time is 0.494014 seconds. solv_vec= 17 4 12 8 1 16 12 8 15 16 solv_vec = 17 4 12 8 1 16 12 8 15 16 dt = 0.4944 Cube Solved Elapsed time is 0.512568 seconds. solv_vec= 1 15 5 1 10 6 4 5 16 1 solv_vec = 1 15 5 1 10 6 4 5 16 1 dt = 0.5130 Cube Solved Elapsed time is 0.543997 seconds. solv_vec= 5 10 7 8 1 18 4 13 8 solv_vec = 5 10 7 8 1 18 4 13 8 dt = 0.5444 Cube Solved Elapsed time is 0.498435 seconds. solv_vec= 7 5 6 15 17 17 7 17 8 12 solv_vec = 7 5 6 15 17 17 7 17 8 12 dt = 0.4988 Cube Solved Elapsed time is 0.520749 seconds. solv_vec= 2 6 8 7 15 16 5 10 15 14 solv_vec = 2 6 8 7 15 16 5 10 15 14 dt = 0.5212 Cube Solved