Rubik's cube translation

Tim Leslie tim.leslie at gmail.com
Sun Mar 30 22:48:34 EDT 2008


On Mon, Mar 31, 2008 at 12:24 PM,  <castironpi at gmail.com> wrote:
> How do I get a Rubik's cube translation out of this:
>
>  >>> a= numpy.array([[0,1,2],[3,4,5],[6,7,8]])
>  >>> a
>  array([[0, 1, 2],
>        [3, 4, 5],
>        [6, 7, 8]])
>  >>> a[:,0],a[:,1],a[:,2] #no good
>  (array([0, 3, 6]), array([1, 4, 7]), array([2, 5, 8]))
>  >>>
>
>  I need [[ 6, 3, 0 ], [ 7, 4, 1 ], [ 8, 5, 2 ]].
>
>  >>> c= numpy.array([[ 6, 3, 0 ], [ 7, 4, 1 ], [ 8, 5, 2 ]])
>  >>> c
>  array([[6, 3, 0],
>        [7, 4, 1],
>        [8, 5, 2]])

In [10]: numpy.rot90(a, 3)
Out[10]:
array([[6, 3, 0],
       [7, 4, 1],
       [8, 5, 2]])

Tim

>  --
>  http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list