Rubik's Cube
It has been over 20 years since I have seriously played with a Rubik's Cube. In 1981, I solved the standard cube. Looking back, I have no idea how I figured it out, but I remember I worked on it for a long time. Then, I solved the 4x4 cube that came out about a year later, but I could not reliably solve it - only most of the time. Then, in 1983 or so, I bought the 5x5 cube (the "Rubik's Professor") and brought it home. My housemate Jim asked if he could try it, as he had been thinking about it for a while. How he could have been thinking about a product that didn't exist was beyond me, but Jim is a way smart guy. Sure enough, one hour later he had solved it. I was suitably impressed, even though Jim declared that he had been thinking about it for a really long time. I did manage to solve the 5x5, but not reliably. Meanwhile the years passed and I forgot absolutely everything I ever knew about the cube. Well, not everything, I could remember some things from Martin Gardner's Scientific American article (about preservation of twists mod 3), but I couldn't solve even the 3x3 cube any longer. Worse, I couldn't even solve the mini-cube, a 2x2 version.
Recently, Emily started playing with one of the 3x3 cubes sitting around the house and I figured it was time to learn how to solve the cube. But this time I wasn't going to start from scratch - I was going to write software to do the work for me - and I knew that I needed to create "moves" - and write them down! I also needed to find a simulator so that I could see if my program was doing the right things. I found a really nice simulator at sourceforge and started writing code to solve the smallest cube - the 2x2 (which is just like the corners of the 3x3 cube, so what I learned on the 2x2 would directly transfer to the 3x3).
My first goal was to find a "swapper" that would swap two of the cubies. I wrote a brute force program that calculated how each of the 12 possible turns of the cube impacted all the cubies and then told it to find a sequence of turns that would swap two particular cubies. I was pleased when it quickly returned the answer of FRUBD. I tested this on the simulator, and sure enough it swap cubies FLU and FRU. And it left all the other cubies in the right position. But there was a problem. All those other cubies were twisted into new orientations, which was definitely not what I wanted. But, just by chance, I discovered that repeating this 5 move sequence two more times preserved the original cubie swapping, but undid all the twisting (which makes sense, as any number of twists repeated 3 times will be 0 mod 3). So, I had a swapper. I went and found our 2x2 mini-cube and quickly got all the cubies in the right position. But I found that two of them were twisted.
So, it was onto my second goal - finding a twister. From the Scientific American article, I remembered that one of the moves discussed was a double twister - e.g. twisting two cubies, one clockwise, the other counter-clockwise. But first I had to figure out how "twists" worked. Figuring how cubies moved was relatively straightforward, even for someone with no spatial skills. But twists were beyond my reach. At this point I had to search for a reference - and found an excellent description of how you would define a twist here. I programmed in the twists and I set the program to look for a double twister that didn't twist any other cubies and didn't move any of the cubies. But I ran into some scalability problems. I had noticed in my reading about twist that I would need at least 14 moves and that would be 12^14 possibilities. Which is 184,884,258,895,036,416 or 184+ quadrillion. Even at 1M turns/sec, this would take 184 billion seconds - and since 1 billion seconds is about 30 years, this was not exactly feasible.
At this point it was time to do a little more "research". This post provides a pretty complete description of the corner twisters, but I only allowed myself to use the basic pattern, which can be characterized by eight possible turns, a very manageable 12^8 = 429,981,696. Ten minutes later, I had an answer. My cubie twister was: R'DRFDF'U'FD'F'R'D'RU.
Applying this move to my 2x2 cube - I had a solved cube. It was the first solved cube I had created in a very long time, and even though I had to do some "research", it was still very rewarding. I let the kids mess it up and solved it again. However, the joy was not to last - as I was practicing the turns of the two moves, my old 2x2 cube came apart in my hands. Unlike the 3x3, which snaps together pretty easily, the 2x2 repair is beyond me.
So, there are many steps remaining:
1. The purchase of a new 2x2 cube
2. Solving the 3x3 cube - by learning an edge swapper and an edge twister
3. Rewriting the solution code for cleanliness
More posts as progress is made.
Comments
By the way, that twister twists LFU and RFU, leaving them in place. And I clearly need a new swapper.
Posted by: Richard Berger | January 15, 2008 06:26 PM