Rubik's Cube/Customize Your Moves

 +-+ +-+ 
 * HOW TO FIND YOUR VERY OWN PERSONAL WAYS TO SOLVE RUBIK'S CUBE                              |
 * (Preliminary April 20, 2007 version)            |
 * by Mr. Ray Calvin Baker                         |
 * FREE Educational Material                       |
 * Chapter Six - - - - - - - - - - Customize Your Moves -- Commutation                        |
 * There is a clever trick which can often be used in manipulating Rubik's Cube (and many     |
 * other puzzles, too). It's called "commutation". When you know how to do something when the |
 * cubies are at the "correct" locations, but some cubies are not at the correct locations,   |
 * try this three step process. First, move the cubies to their "correct" location. (You will |
 * need to remember exactly what moves you made to do this for step three, later. Take notes  |
 * if you must!) Second, do the thing you know how to do. Third, undo whatever you did in the |
 * first step.                                                                                |
 * An example: we know how to convert                                                         |
 * 0 - + + 0   0 0 0 0 0                                                                 |
 * 0 - - + 0 to 0 0 0 0 0                                                                |
 * ^           ^         (all cubies in correct orientation).                            |
 * (Note: I put in the "^" symbol just to emphasize the orientation.)                     |
 * We just use our 0 + - - 0                                                                  |
 * 0 + + - 0 operator, Fv R^ Fv R^ Fv R^.                                     |
 * So, how do we solve                                                                        |
 * + 0 - + +                                                                             |
 * + 0 - - + ?                                                                           |
 * First step: rotate the entire cube to this position:                                       |
 * 0 - + + 0                                                                             |
 * 0 - - + 0                                                                             |
 * Second step: Do Fv R^ Fv R^ Fv R^. This converts                                           |
 * 0 - + + 0         0 0 0 0 0                                                           |
 * 0 - - + 0   to    0 0 0 0 0                                                           |
 * Third step: undo whatever we did in the first step. In this case, we rotate the entire Cube |
 * back to its original orientation, from 0 0 0 0 0   0 0 0 0 0                               |
 * ^        to   ^       .                             |
 * Before you say, "This is strange stuff -- it has no relevance for me!", let me point out   |
 * some uses you have already made using this principle, from previous chapters.              |
 * You have some understanding of how to rotate the entire Cube to any of its 24 possible     |
 * orientations. You have used some of these moves to place several corner cubies in their    |
 * correct locations. In effect, you have learned one series of moves, but you now know 24    |
 * ways to use that series of moves.                                                          |
 * Here is a portion of one of the diagrams from Chapter Four, "Ignoring Details -- Moving    |
 * Corner Cubies". See if you can find some of the ways this principle has been used (even    |
 * though I didn't tell you that you were using it).                                          |
 * (L) klt (K)  : (L) klt (K) : (L) klt (K) : (L) klt (K)    : (L) klt (K)   : (L) klt (K)    |
 * flt T krt   :  flt T frt  :  frt T krt  :  frt T flt     :  krt T flt    :  krt T frt     |
 * F frt  R    :  F  krt  R  :  F  flt  R  :  F  krt  R     :  F  frt  R    :  F  flt  R     |
 * :            :             :  (3-cycle)     :  (diagonal    :  (3-cycle)     |
 * :            :             :                :   corners)    :                |
 * WOW! All 8   : 3R^         : 3Fv         : K^ 3R^ 3T^     : This is done  : K^ 3R^ 3T^     |
 * corner cubies : DO THE SWAP : DO THE SWAP : Diagram 4-2:  : exactly like  : Diagram 4-2:   |
 * are properly : diagram 4-5 : diagram 4-5 : Fv R^ F^ Rv T2 : diagrams 4-8A : Fv R^ F^ Rv T2 |
 * located!     : 3Rv         : 3Fv         : 3Tv 3Rv Kv     : through 4-8J. : 3Tv 3Rv Kv     |
 * :            :             : Then look at   :               :                |
 * :            :             : diagram 4-11F. :               :                |
 * DIAGRAM      : DIAGRAM     : DIAGRAM     : DIAGRAM        : DIAGRAM       : DIAGRAM        |
 * 4-11A.       : 4-11B.      : 4-11C.      : 4-11D.         : 4-11E.        : 4-11F.         |
 * Look at diagram 4-11B. Step one of the useful principle is, "3R^". Step two is, "DO THE    |
 * SWAP". Step three is, "3Rv", which "undoes" step one.                                      |
 * Look at diagram 4-11F. Step one is, "K^ 3R^ 3T^". Step two is, "Fv R^ F^ Rv T2". Step three |
 * is, "3Tv 3Rv Kv", which "undoes" step one.                                                 |
 * Do you remember the clumsy way to exchange two diagonal corner cubies? Here is a much      |
 * easier way! Starting with diagram 4-11E, but using commutation, step one is shown in       |
 * diagram 6-1.                                                                               |
 * (L) klt (K)      (L)_ ? _(K)      (L)_ ? _(K)       (L)_ ? _(K)  Step one:                 |
 * krt T flt        klt T _ ?        ? _ T _flt        klt T _ ?   we have put the           |
 * F frt  R   3R^   |  flt  |  3T^   |  klt  |   Tv    |  flt  |   corner cubies to be       |
 * diagonal  -->   | F | R |  -->   | F | R |   -->   | F | R |   SWAPped into "correct"    |
 * corners)        krt | _ ?        ? _ | _frt        ? _ | _frt  FRT and BFR positions.    |
 * frt             krt               krt                                |
 * (Expanding the diagram                                                        |
 * a little bit)                                                                |
 * DIAGRAM 6-1. Example Step One                                                              |
 * (L)_ ? _(K) Step two:    (L)_ ? _(K)                                                       |
 * klt T _ ?  DO THE SWAP   klt T _ ?                                                        |
 * | flt  |                 |  krt  |                                                        |
 * | F | R |                | F | R |                                                        |
 * ? _ | _frt               ? _ | _frt                                                       |
 * krt                      flt                                                           |
 * DIAGRAM 6-2. Example Step Two                                                              |
 * Step three:   (L)_ ? _(K)       (L)_ ? _(K)       (L)_ ? _(K)       (L) klt (K)     |
 * "Undo" what    klt T _ ?         ? _ T _krt        klt T _ ?         flt T krt      |
 * you did in     |  krt  |   T^    |  klt  |   3Tv   |  krt  |   3Rv   |  frt  |      |
 * step one.      | F | R |   -->   | F | R |         | F | R |   -->   | F | R |      |
 * ? _ | _frt       ? _ | _frt        flt | _ ?         ? _ | _ ?      |
 * flt              flt               frt                ?          |
 * DIAGRAM 6-3. Example Step Three                                                     |
 * Wasn't that much faster and easier than the clumsy way shown in Chapter Four, ""?          |
 * Here is a quick review and summary of how to "undo" one move. (You learned most of this    |
 * when the moves were introduced.).                                                          |
 * B^ undoes Bv.  B2 undoes  B2.  Bv undoes  B^.                                        |
 * F^ undoes Fv.  F2 undoes  F2.  Fv undoes  F^.                                        |
 * K^ undoes Kv.  K2 undoes  K2.  Kv undoes  K^.                                        |
 * L^ undoes Lv.  L2 undoes  L2.  Lv undoes  L^.                                        |
 * B^ undoes Bv.  B2 undoes  B2.  Bv undoes  B^.                                        |
 * B^ undoes Bv.  B2 undoes  B2.  Bv undoes  B^.                                        |
 * 2B^ undoes 2Bv. 2B2 undoes 2B2. 2Bv undoes 2B^.                                       |
 * 2F^ undoes 2Fv. 2F2 undoes 2F2. 2Fv undoes 2F^.                                       |
 * 2K^ undoes 2Kv. 2K2 undoes 2K2. 2Kv undoes 2K^.                                       |
 * 2L^ undoes 2Lv. 2L2 undoes 2L2. 2Lv undoes 2L^.                                       |
 * 2B^ undoes 2Bv. 2B2 undoes 2B2. 2Bv undoes 2B^.                                       |
 * 2B^ undoes 2Bv. 2B2 undoes 2B2. 2Bv undoes 2B^.                                       |
 * 3B^ undoes 3Bv. 3B2 undoes 3B2. 3Bv undoes 3B^.                                       |
 * 3F^ undoes 3Fv. 3F2 undoes 3F2. 3Fv undoes 3F^.                                       |
 * 3K^ undoes 3Kv. 3K2 undoes 3K2. 3Kv undoes 3K^.                                       |
 * 3L^ undoes 3Lv. 3L2 undoes 3L2. 3Lv undoes 3L^.                                       |
 * 3B^ undoes 3Bv. 3B2 undoes 3B2. 3Bv undoes 3B^.                                       |
 * 3B^ undoes 3Bv. 3B2 undoes 3B2. 3Bv undoes 3B^.                                       |
 * DIAGRAM 6-4. Summary: How to Undo One Move                                            |
 * How does one undo a sequence of moves, such as "F^ Rv T^"? Start by considering the last   |
 * move made in "step 1" of the "customizing" process ("T^"), then undo it ("Tv"). Then,      |
 * consider the next- to-last move ("Rv"); undo it ("R^"). Continue this process. Eventually, |
 * you will consider the first move made in "step 1" ("F^"); undo that step ("Fv"). You're    |
 * done undoing the sequence of moves! To summarize the example, undo the sequence "F^ Rv T^" |
 * by doing "Tv R^ Fv".                                                                       |
 * B^ undoes Bv.  B2 undoes  B2.  Bv undoes  B^.                                        |
 * F^ undoes Fv.  F2 undoes  F2.  Fv undoes  F^.                                        |
 * K^ undoes Kv.  K2 undoes  K2.  Kv undoes  K^.                                        |
 * L^ undoes Lv.  L2 undoes  L2.  Lv undoes  L^.                                        |
 * B^ undoes Bv.  B2 undoes  B2.  Bv undoes  B^.                                        |
 * B^ undoes Bv.  B2 undoes  B2.  Bv undoes  B^.                                        |
 * 2B^ undoes 2Bv. 2B2 undoes 2B2. 2Bv undoes 2B^.                                       |
 * 2F^ undoes 2Fv. 2F2 undoes 2F2. 2Fv undoes 2F^.                                       |
 * 2K^ undoes 2Kv. 2K2 undoes 2K2. 2Kv undoes 2K^.                                       |
 * 2L^ undoes 2Lv. 2L2 undoes 2L2. 2Lv undoes 2L^.                                       |
 * 2B^ undoes 2Bv. 2B2 undoes 2B2. 2Bv undoes 2B^.                                       |
 * 2B^ undoes 2Bv. 2B2 undoes 2B2. 2Bv undoes 2B^.                                       |
 * 3B^ undoes 3Bv. 3B2 undoes 3B2. 3Bv undoes 3B^.                                       |
 * 3F^ undoes 3Fv. 3F2 undoes 3F2. 3Fv undoes 3F^.                                       |
 * 3K^ undoes 3Kv. 3K2 undoes 3K2. 3Kv undoes 3K^.                                       |
 * 3L^ undoes 3Lv. 3L2 undoes 3L2. 3Lv undoes 3L^.                                       |
 * 3B^ undoes 3Bv. 3B2 undoes 3B2. 3Bv undoes 3B^.                                       |
 * 3B^ undoes 3Bv. 3B2 undoes 3B2. 3Bv undoes 3B^.                                       |
 * DIAGRAM 6-4. Summary: How to Undo One Move                                            |
 * How does one undo a sequence of moves, such as "F^ Rv T^"? Start by considering the last   |
 * move made in "step 1" of the "customizing" process ("T^"), then undo it ("Tv"). Then,      |
 * consider the next- to-last move ("Rv"); undo it ("R^"). Continue this process. Eventually, |
 * you will consider the first move made in "step 1" ("F^"); undo that step ("Fv"). You're    |
 * done undoing the sequence of moves! To summarize the example, undo the sequence "F^ Rv T^" |
 * by doing "Tv R^ Fv".                                                                       |
 * move made in "step 1" of the "customizing" process ("T^"), then undo it ("Tv"). Then,      |
 * consider the next- to-last move ("Rv"); undo it ("R^"). Continue this process. Eventually, |
 * you will consider the first move made in "step 1" ("F^"); undo that step ("Fv"). You're    |
 * done undoing the sequence of moves! To summarize the example, undo the sequence "F^ Rv T^" |
 * by doing "Tv R^ Fv".                                                                       |