Rubik's cube translation

Tim Roberts timr at probo.com
Tue Apr 1 02:00:14 EDT 2008


castironpi at gmail.com 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, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list