Sitemap
Manan Shah

Manan Shah

The Ideation

3 min readJul 13, 2023

--

13/07/2023 – 1545 hours

Okay so before I get into the details of everything, I decided to keep track of my progress through the projects I make on this website — a detailed, intricate progress which I can look back on and see how I made progress throughout the years.

First up, a website that solves a Rubik’s Cube in any state.

Press enter or click to view image in full size

About the project

I sat on my couch around lunch time, and decided to open r/MachineLearning. Read about a long-time moderator deleting his reddit account due to the third-party tool nonsense that reddit decided to pull, and scrolled down.

Get Manan Shah’s stories in your inbox

Join Medium for free to get updates from this writer.

The stuff on there confounded me — as does AI & ML in general. Hence, I searched “for beginners” within the subreddit, which led me to another sub — r/learnmachinelearning, where I came across this AR model that sees the faces of an IRL cube and is able to solve it.

That basically was the basis of my idea — it is nothing new, I’m sure hundreds of such Rubik’s Cube solving sites exist — but none of them were made by me. This felt like something I’d love to try my hand at — a website where the user enters the configuration of their current cube, and the computer shows the user a step-by-step algorithm to solve the cube.

Learning & Research

Now how to solve a cube IRL is something I know, but how to write code to solve it? 0 clue. Hence, used my best friend Google again.

Turns out — there are around 43,252,003,274,489,856,000 combinations a Rubik’s Cube can have, so brute forcing my way through this was out of the question. Then I also came across this beautiful phenomenon, which actually left me quite astounded — the existence of a God’s number, that is the maximum number of moves required to solve any of the 43 quintillion combinations of a cube. And believe it or not, any cube can be solved within 20 moves. That’s it. Twenty.

I then spent some time reading this blog post — Building a Rubiks Cube Solver With Python 3. It gave me a very base understanding of what algorithm is being implemented to solve a cube in python — a ‘game tree’ approach, which is basically a graph representing all the possible states of the cube from it’s initial state to it’s solved state, and finding the shortest path from source to destination using the Iterative Deepening A* (IDA*) search algorithm. As of the date of this blog post, I have just finished my second semester of engineering, and I have learnt graphs in DSA (including BFS, DFS, Prim’s, Kruskal’s & Djikstra’s Algorithms), so even though IDA* did go majorly over my head, I also understood what it tried to achieve here.

This, though, wasn’t something I could implement on my own yet, but then I came across the Kociemba python library. Named after the famous cube explorer Herbert Kociemba (who also proved the God’s number), this library had a solve() function which took a string input of the cube’s current state and returned a string containing the moves to be performed to solve it. Simple.

--

--