Scripts/1D Rubik's Cube

From J Wiki
Jump to: navigation, search
Rubix1d.png

Template:Tick

Here's an interesting game, found on Andrew Nikitin's MSX-BASIC page http://nsg.upor.net/msx/basic/basic.htm .

1D Rubik's Cube is a line of 6 numbers with original position:

  1 2 3 4 5 6

which can be rotated in 3 different ways in groups of four:

    _______                _______
   (1 2 3 4)5 6  --(0)->  (4 3 2 1)5 6
      _______                _______
    1(2 3 4 5)6  --(1)->   1(5 4 3 2)6
        _______                _______
    1 2(3 4 5 6) --(2)->   1 2(6 5 4 3)

Given a scrambled line, find the shortest sequence of rotations to restore the original position.

See Also


Contributed by Oleg Kobchenko