Algorithms for Solving Rubik’s Cubes

  • Erik D. Demaine
  • Martin L. Demaine
  • Sarah Eisenstat
  • Anna Lubiw
  • Andrew Winslow
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6942)


The Rubik’s Cube is perhaps the world’s most famous and iconic puzzle, well-known to have a rich underlying mathematical structure (group theory). In this paper, we show that the Rubik’s Cube also has a rich underlying algorithmic structure. Specifically, we show that the n ×n ×n Rubik’s Cube, as well as the n ×n ×1 variant, has a “God’s Number” (diameter of the configuration space) of Θ(n 2/logn). The upper bound comes from effectively parallelizing standard Θ(n 2) solution algorithms, while the lower bound follows from a counting argument. The upper bound gives an asymptotically optimal algorithm for solving a general Rubik’s Cube in the worst case. Given a specific starting state, we show how to find the shortest solution in an n ×O(1) ×O(1) Rubik’s Cube. Finally, we show that finding this optimal solution becomes NP-hard in an n ×n ×1 Rubik’s Cube when the positions and colors of some cubies are ignored (not used in determining whether the cube is solved).


combinatorial puzzles diameter God’s number combinatorial optimization 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    World Cube Association. Official results (2010),
  2. 2.
    Cook, S.A.: Can computers routinely discover mathematical proofs? Proceedings of the American Philosophical Society 128(1), 40–43 (1984)Google Scholar
  3. 3.
    Driscoll, J.R., Furst, M.L.: On the diameter of permutation groups. In: Proceedings of the 15th Annual ACM Symposium on Theory of computing, pp. 152–160 (1983)Google Scholar
  4. 4.
    Drucker, A., Erickson, J.: Is optimally solving the n ×n ×n Rubik’s Cube NP-hard? Theoretical Computer Science — Stack Exchange post (August-September 2010),
  5. 5.
    Even, S., Goldreich, O.: The minimum-length generator sequence problem is NP-hard. Journal of Algorithms 2(3), 311–313 (1981)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Fox, F.: Spherical 3x3x3. U.K. Patent 1,344,259 (January 1974)Google Scholar
  7. 7.
    Furst, M., Hopcroft, J., Luks, E.: Polynomial-time algorithms for permutation groups. In: Proceedings of the 21st Annual Symposium on Foundations of Computer Science, pp. 36–41 (1980)Google Scholar
  8. 8.
    Garey, M.R., Johnson, D.S.: Computers and Intractability: A Guide to the Theory of NP-Completeness, 1st edn. Series of Books in the Mathematical Sciences. W. H. Freeman & Co Ltd., New York (1979)zbMATHGoogle Scholar
  9. 9.
    Gustafson, W.O.: Manipulatable toy. U.S. Patent 3,081,089 (March 1963)Google Scholar
  10. 10.
    Ishige, T.: Japan Patent 55-8192 (1976)Google Scholar
  11. 11.
    Jerrum, M.R.: The complexity of finding minimum-length generator sequences. Theoretical Computer Science 36(2-3), 265–289 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Kendall, G., Parkes, A., Spoerer, K.: A survey of NP-complete puzzles. International Computer Games Association Journal 31(1), 13–34 (2008)Google Scholar
  13. 13.
    Krell, U.: Three dimensional puzzle. U.S. Patent 4,600,199 (July 1986)Google Scholar
  14. 14.
    Le., L.: The world’s first 12x12x12 cube. forum post (November 2009),
  15. 15.
    Seven Towns Ltd. 30 years on…and the Rubik’s Cube is as popular as ever. Press brief (May 2010),
  16. 16.
    McKenzie, P.: Permutations of bounded degree generate groups of polynomial diameter. Information Processing Letters 19(5), 253–254 (1984)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Nichols, L.D.: Pattern forming puzzle and method with pieces rotatable in groups. U.S. Patent 3,655,201 (April 1972)Google Scholar
  18. 18.
  19. 19.
    Opatrny, J.: Total ordering problem. SIAM Journal on Computing 8(1), 111–114 (1979)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 20.
    Parberry, I.: A real-time algorithm for the (n 2 − 1)-puzzle. Information Processing Letters 56(1), 23–28 (1995)MathSciNetCrossRefzbMATHGoogle Scholar
  21. 21.
    Ratner, D., Warmuth, M.: The (n 2 − 1)-puzzle and related relocation problems. Journal of Symbolic Computation 10, 111–137 (1990)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Rokicki, T., Kociemba, H., Davidson, M., Dethridge, J.: God’s number is 20 (2010),
  23. 23.
    Schaefer, T.J.: The complexity of satisfiability problems. In: Proceedings of the 10th Annual ACM Symposium on Theory of Computing, San Diego, CA, pp. 216–226 (1978)Google Scholar
  24. 24.
    Schütze, I.: V-cubes Solutions,
  25. 25.
    Sebesteny, P.: Puzzle-cube. U.S. Patent 4,421,311 (December 1983)Google Scholar
  26. 26.
    Slocum, J.: The Cube: The Ultimate Guide to the World’s Bestselling Puzzle — Secrets, Stories, Solutions. Black Dog & Leventhal Publishers (March 2009)Google Scholar
  27. 27.
    V-CUBE. V-cube: the 21st century cube,
  28. 28.
    van Deventer, O.: Overlap cube 2x2x23. shapeways design,

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Erik D. Demaine
    • 1
  • Martin L. Demaine
    • 1
  • Sarah Eisenstat
    • 1
  • Anna Lubiw
    • 2
  • Andrew Winslow
    • 3
  1. 1.MIT Computer Science and Artificial Intelligence LaboratoryCambridgeUSA
  2. 2.David R. Cheriton School of Computer ScienceUniversity of WaterlooWaterlooCanada
  3. 3.Department of Computer ScienceTufts UniversityMedfordUSA

Personalised recommendations