MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Solution 124046

Submitted on 5 Aug 2012 by Richard Zapor

Correct

28Size
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%%
tic
urlwrite('http://tinyurl.com/matlab-rubik-rot','rubik_rot.m') ;
rehash path
toc
```
```{Warning: Function
has the same name as a MATLAB builtin. We suggest you rename
the function to avoid a potential name conflict.}
{> In verifyCode>evaluateCode at 189
In verifyCode at 37
In fevalJSON at 14}
{Warning: Function
has the same name as a MATLAB builtin. We suggest you rename
the function to avoid a potential name conflict.}
{> In verifyCode>evaluateCode at 189
In verifyCode at 37
In fevalJSON at 14}
{Warning: Function
same name as a MATLAB builtin. We suggest you rename the
function to avoid a potential name conflict.}
{> In verifyCode>evaluateCode at 189
In verifyCode at 37
In fevalJSON at 14}
{Warning: Function
the same name as a MATLAB builtin. We suggest you rename the
function to avoid a potential name conflict.}
{> In verifyCode>evaluateCode at 189
In verifyCode at 37
In fevalJSON at 14}
{Warning: Function
same name as a MATLAB builtin. We suggest you rename the
function to avoid a potential name conflict.}
{> In verifyCode>evaluateCode at 189
In verifyCode at 37
In fevalJSON at 14}
{Warning: Function
same name as a MATLAB builtin. We suggest you rename the
function to avoid a potential name conflict.}
{> In verifyCode>evaluateCode at 189
In verifyCode at 37
In fevalJSON at 14}
Elapsed time is 0.831601 seconds.
```
2
Pass

```%%
% 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.016233 seconds.
Elapsed time is 0.039018 seconds.
```
3
Pass

```%%
% 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))
```

4
Pass

```%%
% 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))
```

5
Pass

```%%
% 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;
```

6
Pass

```%%
% 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;