Scale By the Bay Scale By the Bay

Solving the Rubik's Cube with Group Theory


Stewart Stewart
Mission Lane, Principal Engineer

Stewart is a nomadic functional programmer who likes sneaking into conferences and meetups and making friends over the keyboard and a cup of coffee. He is sometimes a consultant and pretends to be good at math. Get his attention by talking about puzzles or books. You can hang out with him and maybe pair program a little at

We've heard all about Monoids, but have you thought about Groups? Group theory has numerous applications in diverse fields, yet the group typeclass usually receives only a passing mention in connection with monoids. As it turns out, groups can be a powerful tool for reasoning about transformations of state.

In this talk, we'll approach group theory from an intuitive angle. We'll learn about the `Group` typeclass and permutations, then see see how theory and functional programming combine to inform the development of a DSL for solving the Rubik's Cube. The presentation will feature live coding and conclude with a demonstration of such a solution using a bluetooth enabled Rubik's Cube. It is my hope that you'll leave with an increased appreciation for the symbiosis between math and FP when it comes to problem-solving, and be able to spot use cases for groups in future problems.