1

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?

Nikunj Vadariya
  • 449
  • 9
  • 19
Felipe Chabatura
  • 61
  • 1
  • 1
  • 6

2 Answers2

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
  • 3
    If 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