Cody

# Problem 882. Solve Rubik's Cube - One Rotation

Solution 2709456

Submitted on 18 Jul 2020
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 %https://sites.google.com/site/razapor/matlab_cody/rubik_rot.m?attredirects=0&d=1 %urlwrite('http://tinyurl.com/matlab-rubik-rot','rubik_rot.m') ; urlwrite('https://sites.google.com/site/razapor/matlab_cody/rubik_rot.m','rubik_rot.m') ; rehash path toc

Elapsed time is 0.326607 seconds.

2   Fail
% For mov=1 solution is 7. Need U' to solve U in 1 move mov_map=[7:12 1:6 13:18]; % Complementary Move mov=1; % U mov_exp1=mov_map(mov); % 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]; tic r=rubik_rot(mov,r); % Create Challenge Cube toc mov=0; assert(isequal(rubik_solve(r),mov_exp1)) toc

Elapsed time is 0.002510 seconds. ans = Columns 1 through 30 5 0 0 5 0 0 5 0 0 1 1 1 1 1 1 1 1 1 4 2 2 4 2 2 4 2 2 3 3 3 Columns 31 through 54 3 3 3 3 3 3 4 4 2 4 4 2 4 4 2 0 5 5 0 5 5 0 5 5

Assertion failed.

3   Fail
% For mov=8 solution is 2. Need F to solve F' in 1 move mov_map=[7:12 1:6 13:18]; % Complementary Move mov=8; % F' mov_exp2=mov_map(mov); % 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]; r=rubik_rot(mov,r); % Create Challenge Cube mov=0; assert(isequal(rubik_solve(r),mov_exp2))

ans = Columns 1 through 30 2 0 0 2 0 0 2 1 1 5 5 5 1 1 1 1 1 1 3 2 2 5 2 2 5 2 2 0 3 3 Columns 31 through 54 0 3 3 0 3 3 4 4 1 4 4 0 4 4 0 4 3 3 4 5 5 4 5 5

Assertion failed.

4   Fail
% For mov=15 solution is 15. Need D2 to solve D2 in 1 move mov_map=[7:12 1:6 13:18]; % Complementary Move mov=15; % D2 mov_ex3p=mov_map(mov); % 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]; r=rubik_rot(mov,r); % Create Challenge Cube mov=0; assert(isequal(rubik_solve(r),mov_ex3p))

ans = Columns 1 through 30 2 0 5 2 0 5 2 0 5 1 1 1 1 1 1 1 1 1 5 2 4 5 2 4 5 2 4 3 3 3 Columns 31 through 54 3 3 3 3 3 3 2 4 0 2 4 0 2 4 0 4 5 0 4 5 0 4 5 0

Assertion failed.

5   Fail
% Anti-Hard code solution Test Case #1 mov_map=[7:12 1:6 13:18]; % Complementary Move mov=randi(18); % anti-hard code Amov_exp=mov_map(mov); % 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]; r=rubik_rot(mov,r); % Create Challenge Cube Amov=mov; mov=0; assert(isequal(rubik_solve(r),Amov_exp),sprintf('mov=%i mov_exp=%i Provided answer=%i\n',Amov,Amov_exp,rubik_solve(r)))

ans = Columns 1 through 30 2 1 1 2 0 0 2 0 0 1 1 1 1 1 1 5 5 5 5 2 2 5 2 2 3 2 2 3 3 0 Columns 31 through 54 3 3 0 3 3 0 4 4 0 4 4 0 4 4 1 4 5 5 4 5 5 4 3 3 ans = Columns 1 through 30 2 1 1 2 0 0 2 0 0 1 1 1 1 1 1 5 5 5 5 2 2 5 2 2 3 2 2 3 3 0 Columns 31 through 54 3 3 0 3 3 0 4 4 0 4 4 0 4 4 1 4 5 5 4 5 5 4 3 3

mov=5 mov_exp=11 Provided answer=1

6   Fail
% Anti-Hard code solution Test Case #2 mov_map=[7:12 1:6 13:18]; % Complementary Move mov=randi(18); % anti-hard code movB_exp=mov_map(mov); % 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]; r=rubik_rot(mov,r); % Create Challenge Cube movB=mov; mov=0; assert(isequal(rubik_solve(r),movB_exp),sprintf('mov=%i mov_exp=%i Provided answer=%i\n',movB,movB_exp,rubik_solve(r)))

ans = Columns 1 through 30 4 0 0 4 0 0 4 0 0 1 1 1 1 1 1 1 1 1 0 2 2 0 2 2 0 2 2 3 3 3 Columns 31 through 54 3 3 3 3 3 3 4 4 5 4 4 5 4 4 5 2 5 5 2 5 5 2 5 5 ans = Columns 1 through 30 4 0 0 4 0 0 4 0 0 1 1 1 1 1 1 1 1 1 0 2 2 0 2 2 0 2 2 3 3 3 Columns 31 through 54 3 3 3 3 3 3 4 4 5 4 4 5 4 4 5 2 5 5 2 5 5 2 5 5

mov=13 mov_exp=13 Provided answer=1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!