The Mathematics of the Rubik’s Cube (2009) [pdf]
I&#x27;ve been fascinated by the Rubik&#x27;s cube for years after learning to solve one in 7th grade. I started to get back into it high school and dropped my solve times down below a minute. Then I continued in college and got down to 25 seconds average with a personal best of 15.15.<p>I created a 2x2 Rubik&#x27;s cube in Java as my freshman final project for my second computer science class, but it was quite ugly.<p>Recently, I decided to take another look at implementing the cube - this time using Python. I also wanted a way to generate cubes and check if they were valid. The main representation of the cube is as a permutation group - a 48-tuple where each element in the tuple is unique. The solved cube is represented as (0, 1, ... , 46, 47).<p>Turns of the cube simply permute this tuple. To figure these all out I spent a lot of time with a cube covered in post it notes.<p>All of the stuff I implemented in the checking for valid cube comes from this stackoverflow post: <a href="https:&#x2F;&#x2F;math.stackexchange.com&#x2F;questions&#x2F;127577&#x2F;how-to-tell-if-a-rubiks-cube-is-solvable&#x2F;127627" rel="nofollow">https:&#x2F;&#x2F;math.stackexchange.com&#x2F;questions&#x2F;127577&#x2F;how-to-tell-...</a><p>I&#x27;ve had a lot of fun working with this cube as my personal project. I recently created a Django website and a RESTful API to display randomly generated cubes. Soon I&#x27;ll be working on a data pipeline to process these random cubes and display them nicely.<p>I&#x27;ve looked into working on a solution algorithm to implement Thistlethwaite&#x27;s algorithm - <a href="https:&#x2F;&#x2F;www.jaapsch.net&#x2F;puzzles&#x2F;thistle.htm" rel="nofollow">https:&#x2F;&#x2F;www.jaapsch.net&#x2F;puzzles&#x2F;thistle.htm</a>. I think this will take me a while, but it should be doable. I haven&#x27;t really though too much about implementing it, but I think the way to do it is to define what it is for each step to be completed and then BFS a graph of moves to end up in that state. If anyone has looked into this I&#x27;d love some advice!<p>You can find the code I&#x27;ve written on Github: <a href="https:&#x2F;&#x2F;github.com&#x2F;elliotmartin&#x2F;RubikLite&#x2F;blob&#x2F;master&#x2F;Rubik.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;elliotmartin&#x2F;RubikLite&#x2F;blob&#x2F;master&#x2F;Rubik....</a>