Tuesday, August 12, 2008

Side project snapshot

Erratum: The original source code posted in this entry was both incorrect and has been moved. The new source code can be found here. Look for the file named rc.py.

* * *

I remember reading in middle school a short story called
The Case of the Missing Will by Agatha Christie. This is a very faint memory, and I had to google for the title, author, and characters to reference it here. What I do remember is the gist of the plot. For those of you too lazy to follow the link to read Wikipedia's plot synopsis, the story is about a detective named Poirot who helps a Miss Marsh discover the whereabout of a missing will. The will was devised by a departed relative who stipulated that Miss Marsh must find the will within a month or else forfeit the inherited fortune. The stipulation was intended to prove whether Miss Marsh is clever enough to deserve the inheritance.

Poirot discovers the will as expected. However, the question arises whether Miss Marsh deserved the inheritance because she didn't find the will herself but used a detective. One of the characters -- possibly Poirot himself -- suggests that by seeking assistance for the search Miss Marsh acted in most clever way and thus deserved the fortune.

***

A coworker brought in a Rubik's Cube, which he now keeps on his desk available for anyone's amusement. I've made fruitless attempts in the past to unlock the Cube's secrets. Not once have I been close, but nevertheless I refuse to look up a solution. However, this time I'm hoping to be a bit more clever and am seeking the assistance of a much brainier associate: my computer.

Below is a quick-and-dirty script I wrote to simulate a Rubik's Cube. My goal is to map out the results of various N-rotation sequences. An example of a 4-move sequence is
top clockwise, left count-clockwise, top counter-clockwise, left clockwise. The result of any N-move sequence leaves some squares with their original color and some with a different color. Working out these results on a real Cube or in my head is too error-prone, for I quickly lose track of which side is which, and working it out on paper is too time-consuming. Hence, my brainier associate, the script.

In theory, if there exists a set of N-move sequences whose only effects are to swap two squares' colors and any two like-squares (corner and sides) can be swapped , then solving a Cube becomes trivial, if not potentially time consuming. Does such a set of sequences exist? Perhaps this script, when automated, can help discover the answer
.

1 comment:

Rachel said...

Okay, your blog makes my head hurt. It's a good thing that I waited until after I had my first sip of coffee to delve into the World of Craig. No seriously, keep up the writing because you truly have a beautiful voice!