Rubik's cube translation

C

castironpi

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]])
 
T

Tim Leslie

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
 
C

castironpi

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:
array([[1, 2, 3],
[4, 5, 6],
[6, 7, 8]])array([[6, 7, 8],
[0, 0, 0],
[0, 0, 0]])

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

?
 
T

Tim Roberts

What if this is connected:
array([[1, 2, 3],
[4, 5, 6],
[6, 7, 8]])array([[6, 7, 8],
[0, 0, 0],
[0, 0, 0]])

-->
array([[1, 2, 3],
[4, 5, 6],
[6, 7, 8]])array([[6, 7, 8],
[0, 0, 0],
[0, 0, 0]])array([[3, 6, 8],
[2, 5, 7],
[1, 4, 6]])
-->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.
 
C

castironpi

What if this is connected:
array([[1, 2, 3],
      [4, 5, 6],
      [6, 7, 8]])
array([[6, 7, 8],
      [0, 0, 0],
      [0, 0, 0]])
array([[1, 2, 3],
      [4, 5, 6],
      [6, 7, 8]])
array([[6, 7, 8],
      [0, 0, 0],
      [0, 0, 0]])
numpy.rot90( D )
array([[3, 6, 8],
      [2, 5, 7],
      [1, 4, 6]])
-->
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top