The api that produces list of all optimal solutions for a given position of Pocket Cube
View Demo »
Base URL : https://pocket-cube-solver.vercel.app/
The purpose of this file is to provide overview, documentation of the api and setup instructions of the project.
The Pocket Cube is a 2*2*2 version of the more popular Rubik's Cube. Even though it is less complex, the pocket cube has 3674160 combinations.
This api returns the list of all optimal solutions ( QTM not HTM ) for a given position string or get a random optimal solution if needed.
-
The api generates a list of solutions array, where each solution is a string of atmost 14-moves. These are optimal solutions of the given position string ( QTM not HTM ).
-
-
R, R', U, U', F, F'
( Learn about cube moves )
-
Returns json data consisting of solutions of a given cube position.
-
URL
/:position/all
-
Method:
GET
-
URL Params
Required:
position=[String]
- This is the position string of a pocket cube position.
-
Success Response:
-
Code : 200
-
Content :
{ "position": "String", "depth": "Integer", "sols": "Array(String)" }
where,
- position stores the parameter inputted,
- depth key contains the number of moves required to solve the given position,
- sols contains the list of all optimal solutions which solves the given position.
-
Example Content :
{ "position": "GBWGYOGYRYOORWROBRWYGWBB", "depth": 11, "sols": [ "R U'R U F'U F'R U F'R'", "R F'R F'U'R R U R'U F'", "R F'R F'U'R'R'U R'U F'", "U U R U'R'U R R F'R F'", "U U R U'R'U R'R'F'R F'", "U'U'R U'R'U R R F'R F'", "U'U'R U'R'U R'R'F'R F'", "F R U'F'U R'F'U R'U R'", "F'R'F U R'U F U'R U R'" ] }
-
-
Error Response:
- Code: 404 NOT FOUND
- Content :
{ "position": "String", "depth": -1, "sols": [] }
- Example Content :
{ "position": "GBWGYOGYRYOORWROBRWYGWBW", "depth": -1, "sols": [] }
- Code: 404 NOT FOUND
Returns json data consisting of an optimal solution of a given cube position.
-
URL
/:position/random
-
Method:
GET
-
URL Params
Required:
position=[String]
-
Success Response:
-
Code : 200
-
Content :
{ "position": "String", "depth": "Integer", "sol": "String" }
where,
- position stores the parameter inputted,
- depth key contains the number of moves required to solve the given position,
- sols contains a random optimal solution which solves the given position.
-
Example Content :
{ "position": "OWWYWRBGOGRGOBWBYYGBORYR", "depth": 9, "sol": "F'R U R'U F'R R F " }
-
-
Error Response:
- Code: 404 NOT FOUND
- Content :
{ "position": "String", "depth": -1, "sol": null }
- Example Content :
{ "position": "OWWYWRBGOGRGOBWBWYGBORYR", "depth": -1, "sol": null }
- Code: 404 NOT FOUND
git clone https://github.com/pavan-k-teja/pocket-cube-solver.git
cd pocket-cube-solver
npm i
npm run dev
Feel free to dive in! Open an issue or submit PRs.