I'm writing something about the relation of 3x3x3
Rubiks cube and theory of computation. I've read some texts talking about the god's number and optimally solutions, but I still can't figure out if solving a rubiks cube optimally is P
or NP
, if it is P
, there is an algorithm to solve it in polynomial time?
Asked
Active
Viewed 1,491 times
1

Nikunj Vadariya
- 449
- 9
- 19

Felipe Chabatura
- 61
- 1
- 1
- 6
-
What _is_ a 3×3×3 Rubik's cube as opposed to, say, a 3×1×5 one? – greybeard Oct 18 '16 at 16:46
2 Answers
2
Solving a 3x3x3 Rubik's cube is O(1). Solving an NxNxN Rubik's cube is almost certainly NP-hard, but I'm not sure if there's a rigorous proof of this. Maybe start looking here: https://cstheory.stackexchange.com/questions/783/is-optimally-solving-the-n×n×n-rubiks-cube-np-hard

Community
- 1
- 1

Tamás Zahola
- 9,271
- 4
- 34
- 46
-
Even if we are talking about optimal solutions? like, the shortest number of moves as possible. – Felipe Chabatura Oct 18 '16 at 13:38
-
It's still O(1) for the 3x3x3 cube. You can make a lookup table of optimal moves for each configuration (the number of configurations for a 3x3x3 cube is O(1), even if it's a very big number). Again, finding the optimal moves for an NxNxN cube in arbitrary configuration is probably very hard. – Tamás Zahola Oct 18 '16 at 13:42
-
It means there is an algorithm that can solve every configuration fo the cube optimally? or theres no realation between these two things? – Felipe Chabatura Oct 18 '16 at 13:49
-
3If something is in P, it is also in NP. I think you mean "almost certainly in NP-hard". – Oct 18 '16 at 13:52
-
I mean, if something is in P, there is an algorithm that can solve it in polynomial time, right? So if, solving a 3x3x3 rubiks cube optimally is in P, there is an algorithm that can solve any instance of the rubiks cube optimally in polynomial time? – Felipe Chabatura Oct 18 '16 at 14:12
-
Yes, there's an algorithm that can solve the 3x3x3 Rubik's cube in polynomial time. Even better: there's an algorithm that can solve the 3x3x3 Rubik's cube in _constant_ time. The brute-force approach will suffice. You see, it's constant time, because the 3x3x3 cube has a fixed, finite number of configurations. It's like saying that you can sort a list of 10 numbers in constant time, because the list length is bounded. You cannot say the same about a list of N numbers, and likewise for the NxNxN Rubik's cube. – Tamás Zahola Oct 18 '16 at 14:27
2
Optimal solution of a NxNxN Rubik's cube is NP-Complete ... as discussed in this paper https://arxiv.org/abs/1706.06708

davide andreazzini
- 239
- 1
- 5