
bring us to our desired state. If not, we increase the depth by one, re-generate our possible
move sequences with this new depth, and keep testing them. We repeat until we find a
sequence of moves that brings us to our desired state.
An example of my program’s testing sequence could look like this:
R, R’, R2, L, L’, L2, U, U’, U2, D, D’, D2, F, F’, F2, R L, R L’, R L2, R U, R U’, …and so on
SInce we always start at depth=1, and don’t increase the depth until we check every
possible move sequence of that depth, we are guaranteed to find the shortest path
to our end state of the cube.
THE CODE:
This snippet of code basically describes the above procedure. We have two nested foreach
loops. The outer one loops through each possible sequence of moves of a depth, and then
inner one loops through each move in that sequence. manipulate(move) takes a move,
and using hardcoded swaps, interchanges the stickers in our corner_init array to apply the
move to our cube.