Solves Rubik's Pocket Cube (2x2x2) by using a simple brute force algorithm in only 100 bytes.
Demos:
- http://jsfiddle.net/aemkei/dDmQf/show/ - Rubik's Mini Cube 2x2x2
- http://jsfiddle.net/aemkei/n2AwP/show/ - Rubik's Cube 3x3x3
You have to pass two movement instructions:
TURN FRONT FACE CW: ROTATE AROUND Y-AXIS:
00 01 01 03
07 05 00 02
04 16 10 08 02 13 23 22 04 05 08 09
06 17 11 09 03 15 21 20 06 07 10 11
14 12 18 16
18 19 19 17
20 21 15 14
22 23 13 12
This will solve the cube in less than a minute (~10.000.000 moves).
The same algorithm may be used to solve the original 3x3x3 cube, but it would take ages to find a solution.
See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.
To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.
140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.
Okay, here is another suggestion that will slow things down but results into 89 bytes:
Replace:
Math.random()<.5
withnew Date%2