Rubik’s cube

Some of the people at work have started a scoreboard of rubik’s cube times, so I’ve been working on getting faster at it. I’ve been maintaining an average time of around 1:20 when I tried, but I was usually just solving it for fun, not trying to improve or even timing myself too often.

They’ve been using CubeTimer.com and solving at work. Unlike them, I don’t sit off in an isolated corner with my team, and my cube is rather noisy. Though I solve my cube at work while waiting on builds, app server restarts, etc I try to keep it quiet instead of solving it fast.

Since I just got an Android phone I checked for a cube timer for it. I found SpeedCube Timer. It’s a pretty decent timer, but it can’t be set to a 3s inspect timer and doesn’t track 3 of 5 average (drop high and low, average the remaining 3). We changed to a 5s inspect timer (since we just need a standard time, 3s was chosen because Calvin didn’t want to have any), but the only metrics on the scoreboard are fastest and 3 of 5 average.

Now I could (and did for a couple days) go through the SpeedCube Timer log and calculate my 3 of 5 average times by hand when I think they’ll turn out well, but that’s time consuming. Since I figured it would be straightforward and felt like brushing up on my Python anyway, I wrote a script to parse the SpeedCube Timer exported log file and calculate all the metrics that cubetimer tracks. That script is posted here.

Here’s the sample output using my log file up to tonight:

Average : 67.48 seconds
Best : 40.74 seconds at July 30 2010 09:18:12 PM
Top Averages:
Avg. 5 : 55.18 seconds from July 30 2010 09:16:19 PM to July 30 2010 09:27:47 PM
3 of 5 : 57.04 seconds from July 30 2010 09:16:19 PM to July 30 2010 09:27:47 PM
Avg. 10 : 61.00 seconds from July 30 2010 09:09:46 PM to July 30 2010 09:32:44 PM
10 of 12 : 61.05 seconds from July 30 2010 09:09:46 PM to July 30 2010 09:37:00 PM

Notice all of my best averages are grouped around my 40s solve (when I got crazy-lucky and all the pieces for the first few steps were on the same side but scrambled, so I didn’t have to look for anything till the last two pieces of the first two layers). My next fastest score is just over 50s currently.

I also realized that Android is a rather open platform and that I could probably find an app somewhere that would interpret Python. Sure enough, I found ASE (or SL4A). By default only the Shell interpreter is installed, but the user guide in the wiki on their site has instructions for installing the Python 2.6.2 interpreter. One of the options for adding a script is by QR Code, so I figured I’d encode my script that way rather than copying the file over the usb connection.

While the ASE wiki claims that the most data that can be put into a QR code is 4,296 characters, actually finding a free QR code generator that will go that big is apparently not easy. The recommended one (ZXing) wouldn’t take such a long query. The next several were the same, but some wanted registration or payment to generate a code. This one actually worked, but it resulted in this monstrosity. I’ve gotten it to scan twice, the first time it said it was an invalid qr code, but the second try actually worked (both times took minutes of attempting to line up the scan box on the screen perfectly with the edges of the QR code displayed on my large monitor). Come to think of it, I probably regenerated the QR code between attempts so I may have forgotten the file name or something the first time. By trimming white-space, comments, display of dates, and file-too-short/missing error handling, and generally making the code unreadable I got it down to 737 characters in this QR code.

To use it you’ll have to export the log from SpeedCube Timer, rename that file to “3 x 3 x 3 Cube.csv” (or change the script), and point the script at the file (the default path in the script is where my Droid Incredible put the file). It’s significantly easier to change/understand the script that’s linked as a .py file (or the big QR code) and that one has more features, but for convenience of transfer the compressed QR one is nice.

Now that everything is finished and working, I think I probably spent more time looking for a QR code generator and trimming my program size to make it fit than I did actually writing the program in the first place.