Cody

Solution 864697

Submitted on 4 Apr 2016
  • Size: 10
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
feval(@assignin,'caller','score',0);

2   Fail
vf=[9 2 11 4 6 8 5 7 21 10 23 12 13 14 15 16 17 3 19 1 20 22 18 24 ; 1 2 13 15 5 4 7 3 10 12 9 11 22 14 21 16 17 18 19 20 6 8 23 24 ; 1 19 3 17 5 6 7 8 9 2 11 4 14 16 13 15 24 18 22 20 21 10 23 12 ; 2 4 1 3 17 18 7 8 5 6 11 12 9 10 15 16 13 14 19 20 21 22 23 24 ; 7 5 3 4 23 6 24 8 9 10 11 12 13 1 15 2 18 20 17 19 21 22 16 14 ; 1 2 3 4 5 6 11 12 9 10 15 16 13 14 19 20 17 18 7 8 22 24 21 23 ; 20 2 18 4 7 5 8 6 1 10 3 12 13 14 15 16 17 23 19 21 9 22 11 24 ; 1 2 8 6 5 21 7 22 11 9 12 10 3 14 4 16 17 18 19 20 15 13 23 24 ; 1 10 3 12 5 6 7 8 9 22 11 24 15 13 16 14 4 18 2 20 21 19 23 17 ; 3 1 4 2 9 10 7 8 13 14 11 12 17 18 15 16 5 6 19 20 21 22 23 24 ; 14 16 3 4 2 6 1 8 9 10 11 12 13 24 15 23 19 17 20 18 21 22 5 7 ; 1 2 3 4 5 6 19 20 9 10 7 8 13 14 11 12 17 18 15 16 23 21 24 22 ; 21 2 23 4 8 7 6 5 20 10 18 12 13 14 15 16 17 11 19 9 1 22 3 24 ; 1 2 22 21 5 15 7 13 12 11 10 9 8 14 6 16 17 18 19 20 4 3 23 24 ; 1 22 3 24 5 6 7 8 9 19 11 17 16 15 14 13 12 18 10 20 21 2 23 4 ; 4 3 2 1 13 14 7 8 17 18 11 12 5 6 15 16 9 10 19 20 21 22 23 24 ; 24 23 3 4 16 6 14 8 9 10 11 12 13 7 15 5 20 19 18 17 21 22 2 1 ; 1 2 3 4 5 6 15 16 9 10 19 20 13 14 7 8 17 18 11 12 24 23 22 21 ; 3 1 4 2 9 10 11 12 13 14 15 16 17 18 19 20 5 6 7 8 22 24 21 23 ; 9 10 11 12 6 8 5 7 21 22 23 24 15 13 16 14 4 3 2 1 20 19 18 17 ; 14 16 13 15 2 4 1 3 10 12 9 11 22 24 21 23 19 17 20 18 6 8 5 7 ; 2 4 1 3 17 18 19 20 5 6 7 8 9 10 11 12 13 14 15 16 23 21 24 22 ; 20 19 18 17 7 5 8 6 1 2 3 4 14 16 13 15 24 23 22 21 9 10 11 12 ; 7 5 8 6 23 21 24 22 11 9 12 10 3 1 4 2 18 20 17 19 15 13 16 14 ; 4 3 2 1 13 14 15 16 17 18 19 20 5 6 7 8 9 10 11 12 24 23 22 21 ; 21 22 23 24 8 7 6 5 20 19 18 17 16 15 14 13 12 11 10 9 1 2 3 4 ; 24 23 22 21 16 15 14 13 12 11 10 9 8 7 6 5 20 19 18 17 4 3 2 1 ]; %r=r(vf(mov,:)); % Standard move, r=rubik_rot_min(mov,r); Pass=1; r_fail=0; % Execute 500 cubes and verify completeness and count moves % initialize cube r(1:4)=0; %Left 0 R r(5:8)=1; %Up 1 W r(9:12)=2; %Front 2 B r(13:16)=3; %Down 3 Y r(17:20)=4; %Back 4 G r(21:24)=5; %Right 5 O rnorm=r; zcnt=500; sum_solve=0; min_solve=1000; max_solve=0; asolve=199; mix=40; tic for cube_check=1:zcnt %zcnt<100 %500 %zcnt=zcnt+1; r=rnorm; % Initial mix mov=randi(18,[mix,1]); for i=1:length(mov) % Ignoring Move Undos since mix=40 r=r(vf(mov(i),:)); end r_reset=r; % Used in assert solve_vec=rubik_solve_mini(r); for i=1:length(solve_vec) r=r(vf(solve_vec(i),:)); end if all(r(1:4)==r(4)) && all(r(5:8)==r(8)) && all(r(9:12)==r(9)) && ... all(r(13:16)==r(13)) && all(r(17:20)==r(17)) && all(r(21:24)==r(21)) solve_vec(solve_vec>18)=[]; % lsolve=length(solve_vec); if lsolve>11, Pass=0;end % Length Rqmt sum_solve=sum_solve+lsolve; min_solve=min(min_solve,lsolve); max_solve=max(max_solve,lsolve); asolve=floor(sum_solve/zcnt); % fprintf('Cube Solved Moves=%i Avg Moves=%i min=%i max=%i\n',lsolve,asolve,min_solve,max_solve) else % Deug info Pass=0; r_fail=r_reset; % fprintf('\n\nCube NOT Solved???\n\n') % fprintf('%i ',r); % Current ending data % fprintf('\n') % fprintf('%i ',r_reset); % Starting Cube end end % while of cubes toc assert(isequal(Pass,1),sprintf('Max Len=%i \n',max_solve)); % Length Exception assert(isequal(Pass,1),sprintf('%i ',r_fail)); % Output Non-Solved Cube Start %if Pass % feval(@assignin,'caller','score',min(100,floor(asolve))); %end fprintf('Moves: Avg %i Min %i Max %i\n',asolve,min_solve,max_solve)

Error using rubik_solve_mini (line 2) Undefined variable "freepass" or class "freepass.please".

3   Fail
vf=[9 2 11 4 6 8 5 7 21 10 23 12 13 14 15 16 17 3 19 1 20 22 18 24 ; 1 2 13 15 5 4 7 3 10 12 9 11 22 14 21 16 17 18 19 20 6 8 23 24 ; 1 19 3 17 5 6 7 8 9 2 11 4 14 16 13 15 24 18 22 20 21 10 23 12 ; 2 4 1 3 17 18 7 8 5 6 11 12 9 10 15 16 13 14 19 20 21 22 23 24 ; 7 5 3 4 23 6 24 8 9 10 11 12 13 1 15 2 18 20 17 19 21 22 16 14 ; 1 2 3 4 5 6 11 12 9 10 15 16 13 14 19 20 17 18 7 8 22 24 21 23 ; 20 2 18 4 7 5 8 6 1 10 3 12 13 14 15 16 17 23 19 21 9 22 11 24 ; 1 2 8 6 5 21 7 22 11 9 12 10 3 14 4 16 17 18 19 20 15 13 23 24 ; 1 10 3 12 5 6 7 8 9 22 11 24 15 13 16 14 4 18 2 20 21 19 23 17 ; 3 1 4 2 9 10 7 8 13 14 11 12 17 18 15 16 5 6 19 20 21 22 23 24 ; 14 16 3 4 2 6 1 8 9 10 11 12 13 24 15 23 19 17 20 18 21 22 5 7 ; 1 2 3 4 5 6 19 20 9 10 7 8 13 14 11 12 17 18 15 16 23 21 24 22 ; 21 2 23 4 8 7 6 5 20 10 18 12 13 14 15 16 17 11 19 9 1 22 3 24 ; 1 2 22 21 5 15 7 13 12 11 10 9 8 14 6 16 17 18 19 20 4 3 23 24 ; 1 22 3 24 5 6 7 8 9 19 11 17 16 15 14 13 12 18 10 20 21 2 23 4 ; 4 3 2 1 13 14 7 8 17 18 11 12 5 6 15 16 9 10 19 20 21 22 23 24 ; 24 23 3 4 16 6 14 8 9 10 11 12 13 7 15 5 20 19 18 17 21 22 2 1 ; 1 2 3 4 5 6 15 16 9 10 19 20 13 14 7 8 17 18 11 12 24 23 22 21 ; 3 1 4 2 9 10 11 12 13 14 15 16 17 18 19 20 5 6 7 8 22 24 21 23 ; 9 10 11 12 6 8 5 7 21 22 23 24 15 13 16 14 4 3 2 1 20 19 18 17 ; 14 16 13 15 2 4 1 3 10 12 9 11 22 24 21 23 19 17 20 18 6 8 5 7 ; 2 4 1 3 17 18 19 20 5 6 7 8 9 10 11 12 13 14 15 16 23 21 24 22 ; 20 19 18 17 7 5 8 6 1 2 3 4 14 16 13 15 24 23 22 21 9 10 11 12 ; 7 5 8 6 23 21 24 22 11 9 12 10 3 1 4 2 18 20 17 19 15 13 16 14 ; 4 3 2 1 13 14 15 16 17 18 19 20 5 6 7 8 9 10 11 12 24 23 22 21 ; 21 22 23 24 8 7 6 5 20 19 18 17 16 15 14 13 12 11 10 9 1 2 3 4 ; 24 23 22 21 16 15 14 13 12 11 10 9 8 7 6 5 20 19 18 17 4 3 2 1 ]; %r=r(vf(mov,:)); % Standard move, r=rubik_rot_min(mov,r); Pass=1; r_fail=0; % Execute 500 cubes and verify completeness and count moves % initialize cube r(1:4)=0; %Left 0 R r(5:8)=1; %Up 1 W r(9:12)=2; %Front 2 B r(13:16)=3; %Down 3 Y r(17:20)=4; %Back 4 G r(21:24)=5; %Right 5 O rnorm=r; for jrand=1:40 % Ignoring Move Undos since mix=40 r=r(vf(randi(18),:)); end q=500; ra=zeros(q,24); for i=1:q for jrand=1:10 % Ignoring Move Undos since base mix=40 r=r(vf(randi(18),:)); end % add 10 new moves to prior vector ra(i,:)=r; end % The Time Trail section does not check accuracy, that is done above t0=clock; for i=1:q solve_vec=rubik_solve_mini(ra(q,:)); end dt=etime(clock,t0)*1000; %assert(isequal(find_fast(a,val(1)),find(a==val(1),1,'first'))) fprintf('Your Time = %i msec\n',floor(dt)) feval(@assignin,'caller','score',min(2000,floor(dt))); % Performance Score

Error using rubik_solve_mini (line 2) Undefined variable "freepass" or class "freepass.please".