Writing a Rubik's Cube Solver using Mathematica
CSEF · 2008 Mathematics & Software Second Award
Overview
Objectives/Goals I enjoy solving the Rubik's cube, and I have developed my own method for solving it. I am interested in mathematics and have written programs to solve Sudoku puzzles and magic squares. I decided to try to write a computer program that solves the Rubik's cube. I wrote the program using the Mathematica software package because Mathematica has built in graphics commands that allowed me to draw the Rubik's cube on a computer screen, and rotate the image using the mouse. Methods/Materials The program I wrote uses 56 simple steps that can be used to solve the cube. I used a recursive algorithm, which applies the 56 basic steps multiple times. This made the program powerful without having to write a large amount of computer code. I then generated a random cube by performing n number of random moves on a completely solved Rubik's cube. I then applied my computer program to solve this scrambled cube. I wrote a small program to repeat this process multiple times and save the number of moves needed to solve the cube. I then took the average and standard deviation of these values. Results I noticed that after the cube had been mixed up by twenty or more moves, the average number of moves needed to solve the cube remained constant at 140 moves. This result shows that after performing twenty random moves, the cube is as scrambled as it can be. Conclusions/Discussion After running the program 25 million times, the highest number of moves needed to solve the Rubik's cube was 222. This suggests that my program can solve the Rubik's cube in or under 222 moves every time. My program can usually solve a Rubik's cube in about 140 moves. On the computer, this takes less than 0.04 seconds! After testing my Rubik's cube solver over 25 million times, I programmed the animations for my Rubik's cube solver so that I could visualize the solutions.
Summary statement
I wrote a computer program to solve a Rubik's cube, evaluated the results, then wrote a program to display animations of the solutions.
Help received
Father taught me the basics of programming when I was ten; Uncle wrote a program with me that solves Sudoku puzzles.
Awards (1)
Competition history
- CSEF 2008
Resources
Related projects
CSEF · 2015
Devising an Effective Way of Solving the Rubiks Cube
CSEF · 2004
Software and Hardware Implementation of Rubik's Cube Solving Algorithms
CSEF · 2011
Cube It: Creating a 3D Rubik's Cube Simulator in C++ and OpenGL
ISEF · 2016
Python Cubed
CSEF · 2014
Speedsolving a Rubik's Cube: Which Algorithms First?
CSEF · 2005
Rubik's Cube Solving Robot, Year Two: Faster Algorithm, Graphical User Interface, and Vision
CSEF · 2005
Variegation and Repeated Sequences on the Rubik's Cube
CSEF · 2002
Rotational Symmetry of Third Order Magic Cubes
Closest projects by meaning, across every fair and year in the corpus.
Browse more like this
Source: California Science & Engineering Fair public projects