From Learning the Rubik's Cube to Building My Own Solver
28 Nov 2026

I've always found the Rubik's Cube fascinating. Watching someone solve one in a few seconds looks a lot like a magic trick, and I never understood how people remembered all those moves.
There's a bar I visit regularly that has a Rubik's Cube lying around. Seeing it there over and over, and picking it up now and then, made me curious whether I could learn to solve it. Around the same time, I was spending quite a few minutes a day waiting for AI tools to finish coding tasks. I started using those breaks to practise. With some YouTube tutorials and the beginner's method, which solves the cube layer by layer, I managed my first solve after about three evenings. Doing it again without help was a different story.
Learning was only the beginning#
Some of the videos were really good at explaining the different situations you can run into. But I didn't want a video playing next to me every time, so I looked for something printable. The cheat sheets I found usually listed the main steps and algorithms, the fixed sequences of moves you memorise, but left out the exceptions that explained when to use which. I ended up switching between videos, websites and PDFs, some of which assumed things I'd never heard of.
Mistakes were the worst part. You can rewind a video, but not the cube in your hands. One wrong turn halfway through an algorithm and I often had no idea where it went wrong, so I'd scramble the whole thing and begin again. Following a video also meant a lot of pausing just to work out which side I was supposed to turn.
I also tried a few apps that scan a scrambled cube and give you a solution. The technology interested me, although some only let me scan a few times before asking me to pay. That made me wonder whether I could build something similar myself, free in a browser, and combine it with a better way of learning: every move playing forwards and backwards on a 3D cube, with the explanations and the awkward cases in one place. That became Cubetorial.
What Cubetorial does today#
The core is a beginner's course in seven steps, from the white cross to twisting the last yellow corners. Each lesson covers the situations you can actually run into, including the exceptions I kept missing. Moves are explained in plain words next to the standard notation, the letters like R and U' that cubers use, and a 3D cube starts from the position in the picture and plays the case. You can step through an algorithm one move at a time, forwards and backwards, and every lesson has a printable cheat sheet that matches what it teaches.

Then there's the cube solver. You show it the six sides of your cube through your camera, it shows the colours it reads so you can fix any, and it plays a short solution move by move on a 3D copy of your cube. It's free, it needs no account, and the camera picture is processed in your browser and never uploaded.
Left and right#
The scanner needs to see all six sides, so between captures it has to tell you which way to rotate the whole cube. On a laptop, Cubetorial mirrors the webcam preview the way video-call apps do, so your right hand shows up on the right. But the camera sees the side of the cube facing it, not the side facing you. Rotate the cube to the right and the side facing the camera moves right, while the side facing you moves left. Both are true at the same moment, and an instruction can only describe one of them.

My first guide showed the rotation from the camera's side, and in one of my own webcam tests I rotated the cube the wrong way: my hands were moving the side facing me. So I rewrote the instructions from the holder's point of view: "Turn the whole cube to your left… the side facing you moves to your left." That made it worse. The video was still a mirror of the camera's side, and now the words described mine. I was looking at the preview, not at my hands.
Less than two hours later the same rotation read "Turn it to the right: the side you just scanned moves to the right." Opposite words for the same movement, and both of them correct. To stop going round in circles, I built three versions to compare:
- A follows the side you just scanned, the way it moves on screen.
- B reverses the arrow, the words and the animation.
- C adds a second arrow, and words, for the side in your hands.
I tried all three with a real cube, and A was the one I could follow without thinking, so A became the default. It's a deliberate trade-off: with a laptop webcam the side facing you still moves the other way, and it needs testing with other webcams and other people.
In my own tests this kept happening: the guide was correct and still confusing. One version used a see-through cube, and in one session it looked as if the animation or the arrow was reversed. Neither was. A transparent cube can be read two ways, the same kind of ambiguity as the Necker cube illusion. A solid cube removed that ambiguity.

Another problem appeared on launch day, the first time I scanned on an iPhone. The scan gave no solution and red and orange looked swapped, but colour recognition wasn't to blame: I'd held three sides upside down, and the scanner put two of them in each other's places. Now, when the captured sides can't form a real cube, the scanner rebuilds it from the colours alone, trying every way each side could have been held. If exactly one real cube fits, it shows that result on the check screen with a note and lets you check the colours before solving. If none or more than one fits, it doesn't guess.
Six colours shouldn't be this hard#
I'd used webcams before, tracking faces in Eyebrow Tetris and hands for map controls with MediaPipe, so six colours sounded easy. But webcams adjust their colours all the time, a desk lamp is yellow and daylight is blue, stickers reflect, and red and orange are close neighbours to begin with. In the very first test with a real cube, blue squares were read as green, green as yellow and orange as red. Part of that was a bug: the scanner compared stickers with whatever centre the camera was looking at, even when it was a different side from the one it expected.

The idea behind the fix was to let the cube calibrate itself, properly this time. The centre pieces are fixed to the cube's core, so each side always has the same colour in its middle. That makes every cube its own colour chart, seen by your camera in your light. Cubetorial now compares each sticker only with the centres you've actually captured, instead of with a textbook red. In a simulation with four kinds of sticker plastic under five lights, matching against typical colours in RGB got 71% of the stickers right, HSV thresholds 89%, and the cube's own centres, once all six were captured, all of them. That's a simulation, not a measured accuracy. I don't have a real-world figure yet.
Red and orange needed extra care. In one webcam test a bright red sticker measured as close to the cube's orange as to a typical red. Switching to CIE94, a colour difference formula that counts a difference in saturation less than a difference in hue, made it clearly red. Brightness already counted for less than colour, so shadows matter less too.
A few smaller things help. After the first capture the scanner locks the camera's white balance and exposure where the browser and camera allow it. Otherwise a mostly red side can make the camera "correct" the picture towards blue-green. When the scanner isn't sure, it shows a question mark instead of guessing, and you can tap any square to fix it. Your correction then becomes an extra reference for that colour.

The logo on the white sticker#
Plenty of cubes have the manufacturer's logo printed on the white centre sticker. The scanner used to read only the middle half of each square, which keeps the black gaps and neighbouring stickers out. But a logo sits exactly in the middle of the centre sticker, and a blue logo half the sticker's width covered most of that area, so the scanner read white as blue. The white centre is also the reference for every other white sticker, so one logo didn't break one square, it broke the meaning of "white" for the whole cube. In a simulated test of twelve complete scans with that logo, not one cube was read correctly.
I didn't want brand-specific rules or a machine learning model for something this small. The scanner now samples a grid of points across almost the whole sticker, groups them by colour and lets the biggest group win. A logo is a smaller group, so it's outvoted instead of blended in.

In the same simulation all twelve scans came out right, and centred logos up to 60% of the sticker's width were read correctly. Bigger than that, the scanner starts asking, and once a print covers about half the sticker's area it simply is the biggest colour. I also scanned a real cube with a logo through my laptop webcam and kept its colour readings as a test case: all 54 stickers were named correctly. That's one solved cube in one light, so glossy and embossed logos and other lighting still need testing.
Teaching a cube versus solving one#
My original plan was to connect the scanner to the lessons: scan your cube, and Cubetorial takes you through the beginner's method from wherever you are. I built that, and it works. Then I compared the two on one scanned cube: the lesson route took 166 moves, counting every whole-cube rotation, and the computer solver needed 18. One cube isn't a fair benchmark, so I later counted both the same way on 300 random cubes, leaving out rotations and counting a half turn as one move. The lesson route needed a median of 145 turns. Across those 300 cubes, the solver never needed more than 20 turns, and most of its solutions were exactly 20.
Neither number is wrong. The beginner's method repeats a handful of memorable algorithms until each piece lands, which is what makes it learnable. A computer solver looks for a short solution to this one cube, not a sequence that's easy to learn and remember. I'd been mixing two goals, teaching someone to solve a cube and getting the cube in their hands solved, so I separated them. The public solver gives the short solution, and the lessons are where you learn to do it yourself. The lesson route didn't disappear, though. On lessons 2 to 7, if your cube isn't at that step yet, you can scan it and the lesson shows the earlier steps' moves to get you there.
I didn't invent a new way for computers to solve a cube. The solver is min2phase, Chen Shuang's implementation of Herbert Kociemba's two-phase algorithm, in the copy that ships with cubing.js, the open-source library I already used for the 3D cube, with a small patch so it can be asked for a maximum length. Roughly, it first works the cube into a position that can be finished with a restricted set of moves, then finishes it. Cubetorial asks for the first solution of 20 moves or fewer, which every cube has. If the search takes more than four seconds, Cubetorial falls back to a faster solution of up to 21 moves. Either way it's short, but not guaranteed to be the shortest for your cube.
The maths behind that search is a different subject from the beginner's method I practise, and not one I'd claim to understand in depth. My part was everything around it: turning six camera pictures into a cube, rotating it to the orientation the solver expects, translating the moves back to the way you're holding your cube, and replaying them to check they really solve it before showing the result.

Building it with AI, and checking the results#
AI tools were part of the reason I started learning the cube, and they ended up playing a large part in building Cubetorial too. I used Claude for most of the implementation, and the first public version took about a week of trying things on a real cube and throwing them away. Knowing whether the result was right took more effort than writing it, especially because I'm still learning and can't always tell a wrong lesson from my own mistake.
So I set up a "learner": code that follows only the lessons' stated rules and printed moves, the way a beginner following them literally would. It ran through 2,000 random scrambles. Every one had to end solved, after every step everything solved earlier had to still be in place, and every case the lessons teach had to come up at least once.
Building it turned up gaps. Given a cube with the cross already done, the White Cross lesson had no "you're already done" rule, so someone following it literally would take the cross apart again. Later, a fix of my own gave the final step two counting rules that didn't agree, and a check caught it within minutes. Earlier checks had already found that the cheat sheet I'd used as a source showed a colour scheme no real cube can have.
Tests can't tell you whether a lesson is easy to understand. They're very good at telling you when it's wrong. For clarity, I set up AI reviewers with different roles, including a UX designer, an accessibility reviewer and a simulated first-time solver who only got screenshots and page text. Over three rounds they caught unclear wording, small tap targets and missing steps. Simulated personas aren't people, though, and they tend to agree with each other more than real people would.
Before launch, an AI audit covering SEO, content, accessibility, privacy and cube correctness came back with "NO-GO today". Among other things, the solver had never run on a real phone. Four of its reviewers separately caught the same false line in the solver: a closing message that wrongly said your cube would end up held a different way. The cube review also wrote its own sticker model, separate from the app's code, and ran its own 2,000 scrambles. That's a useful cross-check, but it was written with AI too. The human testing so far is mine, with real cubes on a laptop and an iPhone.
What I learned, and what's next#
I started with a puzzle and ended up dealing with cameras, colour and perspective. The camera, the mirror, the person and the 3D model each have their own idea of left and right, and the interface has to pick one and stick to it. Something can be correct without being clear, and I only found out which was which by picking up a real cube.
I'm still learning the cube myself. I've been practising for about a month now, and my personal best is one minute and 35 seconds. That's a best, not my usual time, and the last layer still makes me stop and think. Cubetorial is live and will keep changing. Next I'd like to add faster methods such as CFOP (which I'll have to learn first) and cube patterns. The scanner also needs more cubes, cameras and, most of all, people who aren't me.
So if there's a cube in a drawer somewhere, give Cubetorial a try. If it misreads your colours, or a lesson loses you somewhere, I'd like to hear about it.


