Rubik's cube translation

Discussion in 'Python' started by castironpi@gmail.com, Mar 31, 2008.

  1. Guest

    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]])
    , Mar 31, 2008
    #1
    1. Advertising

  2. Tim Leslie Guest

    On Mon, Mar 31, 2008 at 12:24 PM, <> 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
    >
    Tim Leslie, Mar 31, 2008
    #2
    1. Advertising

  3. Guest

    On Mar 30, 9:48 pm, "Tim Leslie" <> wrote:
    > On Mon, Mar 31, 2008 at 12:24 PM,  <> 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


    What if this is connected:

    >>> D

    array([[1, 2, 3],
    [4, 5, 6],
    [6, 7, 8]])
    >>> E

    array([[6, 7, 8],
    [0, 0, 0],
    [0, 0, 0]])

    -->

    >>> D

    array([[1, 2, 3],
    [4, 5, 6],
    [6, 7, 8]])
    >>> E

    array([[6, 7, 8],
    [0, 0, 0],
    [0, 0, 0]])
    >>> numpy.rot90( D )

    array([[3, 6, 8],
    [2, 5, 7],
    [1, 4, 6]])
    -->
    >>> E

    array([[1, 4, 6],
    [0, 0, 0],
    [0, 0, 0]])

    ?
    , Mar 31, 2008
    #3
  4. Tim Roberts Guest

    wrote:
    >
    >What if this is connected:
    >
    >>>> D

    >array([[1, 2, 3],
    > [4, 5, 6],
    > [6, 7, 8]])
    >>>> E

    >array([[6, 7, 8],
    > [0, 0, 0],
    > [0, 0, 0]])
    >
    >-->
    >
    >>>> D

    >array([[1, 2, 3],
    > [4, 5, 6],
    > [6, 7, 8]])
    >>>> E

    >array([[6, 7, 8],
    > [0, 0, 0],
    > [0, 0, 0]])
    >>>> numpy.rot90( D )

    >array([[3, 6, 8],
    > [2, 5, 7],
    > [1, 4, 6]])
    >-->
    >>>> E

    >array([[1, 4, 6],
    > [0, 0, 0],
    > [0, 0, 0]])
    >
    >?


    If you don't want changes to D to affect E, then you need to disconnect
    them when you create them. If you create D and E so that they contain
    references to the same lists, then this kind of thing will happen.
    --
    Tim Roberts,
    Providenza & Boekelheide, Inc.
    Tim Roberts, Apr 1, 2008
    #4
  5. Guest

    On Apr 1, 1:00 am, Tim Roberts <> wrote:
    > wrote:
    >
    > >What if this is connected:

    >
    > >>>> D

    > >array([[1, 2, 3],
    > >       [4, 5, 6],
    > >       [6, 7, 8]])
    > >>>> E

    > >array([[6, 7, 8],
    > >       [0, 0, 0],
    > >       [0, 0, 0]])

    >
    > >-->

    >
    > >>>> D

    > >array([[1, 2, 3],
    > >       [4, 5, 6],
    > >       [6, 7, 8]])
    > >>>> E

    > >array([[6, 7, 8],
    > >       [0, 0, 0],
    > >       [0, 0, 0]])
    > >>>> numpy.rot90( D )

    > >array([[3, 6, 8],
    > >       [2, 5, 7],
    > >       [1, 4, 6]])
    > >-->
    > >>>> E

    > >array([[1, 4, 6],
    > >       [0, 0, 0],
    > >       [0, 0, 0]])

    >
    > >?

    >
    > If you don't want changes to D to affect E, then you need to disconnect
    > them when you create them.  If you create D and E so that they contain
    > references to the same lists, then this kind of thing will happen.


    Basically, I need to change both D row 3 and E row 1 at the same time.
    , Apr 1, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrwoopey
    Replies:
    3
    Views:
    2,259
    pipodyer
    May 9, 2006
  2. Joel Leong
    Replies:
    3
    Views:
    3,162
    Scott Allen
    Apr 19, 2005
  3. sarah28
    Replies:
    3
    Views:
    994
    sarah28
    Jun 26, 2003
  4. Cube root computation

    , Jan 16, 2006, in forum: C Programming
    Replies:
    2
    Views:
    569
    Randy Poe
    Jan 16, 2006
  5. John Kelly

    OT: Rubik's Cube

    John Kelly, Aug 16, 2010, in forum: C Programming
    Replies:
    2
    Views:
    369
    John Kelly
    Aug 17, 2010
Loading...

Share This Page