Skip to content
A generic rubiks cube solver
Branch: master
Clone or download
Latest commit 999459b Jul 1, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
misc 555 increase number of test cubes from 10 to 50 Mar 13, 2019
rubikscubennnsolver Enforce python3 Jun 14, 2019
usr/bin Enforce python3 Jun 14, 2019
utils Ran 'black' to format Jun 14, 2019
www Initial commit Aug 13, 2017
.gitignore 555 fix edges bug with 2nd L4E group Aug 20, 2018
LICENSE Update LICENSE Apr 18, 2019
Makefile tweak 'make clean' Jul 1, 2019
README.md Updated README Feb 8, 2019
ida_search.c ida_search_555.c added get_edges_paired_count Mar 29, 2019
ida_search_444.c 444 phase3 use heuristic_stats_error of 1 Feb 17, 2019
ida_search_444.h Added --fast --normal --slow Oct 20, 2018
ida_search_555.c get_wings_paired_count ignore edges that are ghosted out Mar 29, 2019
ida_search_555.h Added --fast --normal --slow Oct 20, 2018
ida_search_666.c Update 666 comment Feb 9, 2019
ida_search_666.h 666 move step60 to IDAViaC Feb 7, 2019
ida_search_777.c fix gcc warnings Nov 19, 2018
ida_search_777.h Added --fast --normal --slow Oct 20, 2018
ida_search_core.c 444 groundwork for tsai phase3 viaC Oct 3, 2018
ida_search_core.h Added --fast --normal --slow Oct 20, 2018
rotate_xxx.c 666 step20: use C for IDA Aug 18, 2018
rotate_xxx.h 444: step10 use IDAViaC..removed cLibrary.c Sep 3, 2018
setup.py Ran 'black' to format Jun 14, 2019
uthash.h Added ida_search.c Dec 2, 2017
xxhash.c
xxhash.h Added lookup-table-6x6x6-step31-LR-oblique-edges-stage.txt Aug 21, 2018

README.md

rubiks-cube-NxNxN-solver

Overview

This is a rubiks cube solver that can solve any size cube, I have tested up to 17x17x17. The following tables show the reduction in move counts as the solver has evolved. The --normal table starts in July 2018, the earlier releases of the solver had drastically higher move counts, I think it was over 400 moves the first time I solved a 5x5x5.

Solving a 2x2x2 takes around 9 moves while solving a 3x3x3 takes around 20 moves but I am not working on those solvers so I did not include them in the tables below.

--fast mode

Move Counts

Date Commit 4x4x4 5x5x5 6x6x6 7x7x7 8x8x8 9x9x9 10x10x10
2/07/2018 baseline 63 106 180 235 357 468 637

Memory Requirements

Size Memory
4x4x4 75M
5x5x5 175M
6x6x6 400M
7x7x7 400M
NxNxN 400M

--normal mode

Move Counts

Date Commit 4x4x4 5x5x5 6x6x6 7x7x7 8x8x8 9x9x9 10x10x10
10/17/2018 TBD 50 88 156 218 344 430 601
09/24/2018 TBD 50 88 156 218 344 454 630
09/17/2018 TBD 50 103 160 221 346 444 614
08/24/2018 9dc52a7 50 103 161 224 346 469 617
08/20/2018 39bf371 50 103 162 228 366 466 636
08/19/2018 6b8993a 50 103 165 244 362 513 669
08/13/2018 b754e60 50 107 165 244 362 513 669
08/13/2018 bdbbd46 52 107 165 244 362 513 669
07/16/2018 456ddd1 52 107 172 247 376 520 725
07/12/2018 c9484d9 60 107 176 247 386 520 743
07/12/2018 5cda2c8 60 107 181 247 386 520 743
07/08/2018 9c13b16 60 107 181 257 403 531 743
07/07/2018 e876493 60 107 181 272 408 556 768
07/04/2018 60 107 200 278 408 556 768

Memory Requirements

Size Memory
4x4x4 500M
5x5x5 4.0G
6x6x6 4.0G
7x7x7 4.0G
NxNxN 4.0G

Install

Install 3x3x3 solver

The kociemba solver is required to solve the larger cubes that have been reduced to 3x3x3.

$ git clone https://github.com/dwalton76/kociemba.git
$ cd ~/kociemba/kociemba/ckociemba/
$ make
$ sudo make install

Install the rubikscubennnsolver python module

$ sudo pip3 install pyhashxx
$ cd
$ git clone https://github.com/dwalton76/rubiks-cube-NxNxN-solver.git
$ cd rubiks-cube-NxNxN-solver
$ sudo make all

Usage

Run rubiks-cube-solver.py where --state is your cube state in kociemba order (URFDLB). You must run rubiks-cube-solver.py from the directory that holds your lookup-table*.txt files

Example:

$ cd ~/rubiks-cube-NxNxN-solver
$ ./usr/bin/rubiks-cube-solver.py --state LFBDUFLDBUBBFDFBLDLFRDFRRURFDFDLULUDLBLUUDRDUDUBBFFRBDFRRRRRRRLFBLLRDLDFBUBLFBLRLURUUBLBDUFUUFBD

History

One of my hobbies is building Lego Mindstorms robots that can solve rubiks cubes. I was able to find solvers for 2x2x2, 3x3x3, 4x4x4 and 5x5x5 but I couldn't find a solver for anything larger than that :( The solvers that I did find for 4x4x4 and 5x5x5 took quite a bit of RAM (several gigs) but I wanted to be able to run the solver on a Lego Mindstorms EV3 which is 300Mhz and 64M of RAM. So I decided to write my own solver and here we are :)

Here is the thread on speedsolving.com where I first posted looking for solvers. I ended up posting updates to this thread as my solver evolved: https://www.speedsolving.com/forum/threads/5x5x5-6x6x6-7x7x7-or-nxnxn-solvers.63592/

Examples

2x2x2
=====
reset; ./usr/bin/rubiks-cube-solver.py --state DLRRFULLDUBFDURDBFBRBLFU


3x3x3
=====
reset; ./usr/bin/rubiks-cube-solver.py --state RRBBUFBFBRLRRRFRDDURUBFBBRFLUDUDFLLFFLLLLDFBDDDUUBDLUU


4x4x4
=====
reset; ./usr/bin/rubiks-cube-solver.py --state FLDFDLBDFBLFFRRBDRFRRURBRDUBBDLURUDRRBFFBDLUBLUULUFRRFBLDDUULBDBDFLDBLUBFRFUFBDDUBFLLRFLURDULLRU


5x5x5
=====
reset; ./usr/bin/rubiks-cube-solver.py --state LLFBRBFUDULBULBBDDUBBBBLDFDULDLURFBDFRLDUFDBRLDUFBLURFRFRDRBULFBLLLBURUFRFURDDLBULLLRLRDFRDRBBRUDFDUFRBUDULFDUFULDFRBRBULLUFFBLRDDDDFRRBUBRLBUUFFRRDFF


6x6x6
=====
reset; ./usr/bin/rubiks-cube-solver.py --state FBDDDFFUDRFBBLFLLURLDLLUFBLRFDUFLBLLFBFLRRBBFDRRDUBUFRBUBRDLUBFDRLBBRLRUFLBRBDUDFFFDBLUDBBLRDFUUDLBBBRRDRUDLBLDFRUDLLFFUUBFBUUFDLRUDUDBRRBBUFFDRRRDBULRRURULFDBRRULDDRUUULBLLFDFRRFDURFFLDUUBRUFDRFUBLDFULFBFDDUDLBLLRBL


7x7x7
=====
reset; ./usr/bin/rubiks-cube-solver.py --state DBDBDDFBDDLUBDLFRFRBRLLDUFFDUFRBRDFDRUFDFDRDBDBULDBDBDBUFBUFFFULLFLDURRBBRRBRLFUUUDUURBRDUUURFFFLRFLRLDLBUFRLDLDFLLFBDFUFRFFUUUFURDRFULBRFURRBUDDRBDLLRLDLLDLUURFRFBUBURBRUDBDDLRBULBULUBDBBUDRBLFFBLRBURRUFULBRLFDUFDDBULBRLBUFULUDDLLDFRDRDBBFBUBBFLFFRRUFFRLRRDRULLLFRLFULBLLBBBLDFDBRBFDULLULRFDBR


8x8x8
=====
reset; ./usr/bin/rubiks-cube-solver.py --state DRRRURBDDBFBRBDDBRRDUFLLURFBFLFURLFLFRBRFUBDRFDFUUBLFFFUULBBFDBDFBUBBFRFLRDLFDRBBLLFRLDFDRBURULDDRFFBFUUBLLFBRUUFDUBRDBBRDFLURUUFFUDLBRRFDUBFLRUUFFRLBFRFLRULUDFRUBBDBFFLBBDFDFLDBFRRRDDLFLBRBFBBRULDDUUBLBBURULLDDLDRUDRBUDRLUULDURLRDFLFULUFLFULRDDDUBBULRBRDFBBLFURRLULUBDDULRFBRFURBRLBRUBULBDDFBUFFBBRLRUUUFRULLBFFRFDDFFDULLDLBUDLLLLUUBBLDLLBBULULBDUDDFUBFLLDLDLFRDUDDBRRFRURRFRRLDDDDRD


9x9x9
=====
reset; ./usr/bin/rubiks-cube-solver.py --state RFBLRUFLLFFLRRBDUDDBBBDUDFRUDUFFFBBFRBRDURBULFUDDFLLLDLFLRDLDBBBUUBRDBBBDFUFRUURULURBURDLFDUBFFDRDFRUBDUBRFLRRLUDLRLFBLBRRLLRDRBRBLURBLLRFRLDDFFFRBFUFURDFRRUDUFDDRRRLFLLUBBLBFDRRDLBRLUUBRDBBUBFLUUFBLLDBFFFBUFBFDBRDDDFLRFFBFFFLFRRDUUDDBUBLUUDURRBDBFFLFURDDLUBULUULULBFBRUBLLDDFLRBDBRFDUUDFURLLUBUFBLULLURDLLLBLFFRLLBLUDRLRDBLDDBRBUDRBLLRDUUUBRRFBFBBULUDUDLDRFUDDDFULRFRBDUDULBRRDBDFFRUUFRRFBDBLFBBDFURLRFDUUFRLUBURFURDDFLDFUBDFRRURRDLUDRBRBDLBFLBBRDLRDBFDUBDFFUBLFLUULLBUDLLLURDBLFFFDFLF


10x10x10
========
reset; ./usr/bin/rubiks-cube-solver.py --state ULBDLDBUFRBBBBBLBFFFDFRFBBDDFDFRFFLDLDLURRBUDRRBFLUDFRLBDURULRUUDBBBUBRURRRLDLRFFUFFFURRFBLLRRFLFUDBDRRDFULLLURFBFUUBDBBDBFLFDFUUFDUBRLUFDBLRFLUDUFBFDULDFRUBLBBBUBRRDBDDDDFURFLRDBRRLLRFUFLRDFDUULRRDULFDUDRFLBFRLDUDBDFLDBDUFULULLLBUUFDFFDBBBRBRLFLUFLFUFFRLLLFLBUDRRFDDUDLFLBRDULFLBLLULFLDLUULBUDRDFLUDDLLRBLUBBRFRRLDRDUUFLDDFUFLBDBBLBURBBRRRFUBLBRBRUBFFDBBBBLBUFBLURBLDRFLFBUDDFFRFFRLBDBDUURBUFBDFFFLFBDLDUFFBRDLBRLRLBFRUUUULRRBDBRRFDLLRRUUBDBDBFDLRDDBRUUUUUBLLURBDFUFLLRDBLRRBBLBDDBBFUDUDLDLUFDDDUURBFUFRRBLLURDDRURRURLBLDRFRUFBDRULUFFDUDLBBUURFDUDBLRRUDFRLLDULFUBFDLURFBFULFLRRRRRFDDDLFDDRUFRRLBLUBU


11x11x11
========
reset; ./usr/bin/rubiks-cube-solver.py --state URBDLBURUBUFDDRBUFDDUBFRDBLRFUUBLDRLBBUBLUFBLRBFFDDLLLDRULRBUDBBRLULBUUUFFRUBLUFUUBRLBLUUDRLDUBLUFDLBLFDBLFRLFLRUDFLLLDFULDRFDFLLFLLRDUUDRFRFFFFBFRBFRFUUBBUULURLULBBLLDDLBUFRURBLFFBRFFRRURFUFLLRUFDBDDDBLRDUBLBRBLRLBUBULLBBFRBFRBLFUDDULLF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