3 ms·
When my daughter got into rubik's cube with her friends, I thought it would be fun to use it as a sample to teach her about applying a simple breadth-first solv
by pge 9y ago
When my daughter got into rubik's cube with her friends, I thought it would be fun to use it as a sample to teach her about applying a simple breadth-first solver to find the shortest path to a solution. Embarrasingly, I neglected to do the math on how many possible states there were before we started. We coded up the solver in just a few minutes, but quickly discovered that a typical solution would take longer than either of our lifetimes...Oops. She learned some coding that day - not the lesson I intended, but probably a more important one!
- timjver 9y agoIt only took you a few minutes, together with your daughter, to write code that lets you interact with a Rubik's Cube? Or were you only referring to the solver part?
- tripa 9y agoEven the solver part is impressive. A BFS is a few seconds, but modeling a Rubik's cube properly in a way a daughter would understand is... harder.
- pge 9y agoYes, that part was over her head. I did all the coding, and the representation of the cube and the moves. She got the concepts of the search, but capturing the changes in the cube when a face is rotated was too complicated to do with her.
- pge 9y agoIt was just a simple solver - you typed in the faces at a command line, and it spit out the moves. It was brute force breadth-first, so nothing fancy...