How to write a Rubik's cube solver

Sam Saariste

⏱ 90 minute session
intermediate
advanced
11:30-13:00, Friday, 4th April 2025
In this talk I share a journey of developing a Rubik's cube solving library that can be used for a wide range of applications in this space. The original purpose was to teach Python to my 12 year old son who happens to be able to solve a Rubik's cube in 10 seconds. Soon, this teaching project turned into a shared quest to design a Rubik's cube solving framework that can be used as a teaching tool to do sample solves at all possible skills levels, but also as a tool to find optimal solutions for specific cases that speed solvers may come across. We even modelled how efficient a human could execute a sequence of turns depending on whether regrips will be necessary, which is important for speedsolvers who execute up to 15 turns per second. We tried different datastructures for cube representations and settled on an efficient one with some very interesting properties allowing for elegant solutions. I will show how a "dumb" solver for specific problems, such as solving the first for edge pieces, can find optimum solutions quickly without requiring any heuristics or prior cubing knowledge. Define a cost function in combination with some dynamic programming provides a solution that has proven very successful for us. You are not expected to know how to solve a Rubik's cube, but you may get interested as a result. If you do how to solve a cube, you may find it even more interesting.
🏷 Python
🏷 data structures
🏷 solvers
🏷 libraries

Sam Saariste

Sam is a software developer with 30 years of experience. He is specialised in C++ but also has experience with other languages such as Python and C#. He has worked in the financial sector for the past 20 years. Sam loves finding efficient and elegant technical solutions irrespective of the technology at hand.

One of Sam's favourite hobbies in the past few years has been solving Rubik's cubes. He has learned several methods and over one hundred different algorithms and loves to teach friends and colleagues how to solve the cube, or how to solve it more efficiently and has developed a program that can solve any randomly scrambled cube with various methods and skill levels while giving explanations for each step.