#NEWLINE# def rotate_NxN( m ) : #NEWLINE# #INDENT# n = len ( top ) #NEWLINE# for layer in range ( ( n // 2 ) ) : #NEWLINE# #INDENT# first = layer #NEWLINE# last = ( ( n - 1 ) - layer ) #NEWLINE# for i in range ( first , last ) : #NEWLINE# #INDENT# offset = ( i - first ) #NEWLINE# top = m [ first ] [ i ] #NEWLINE# m [ first ] [ i ] = m [ ( last - offset ) ] [ first ] #NEWLINE# m [ ( last - offset ) ] [ first ] = m [ last ] [ ( last - offset ) ] #NEWLINE# m [ last ] [ ( last - offset ) ] = m [ i ] [ last ] #NEWLINE# m [ i ] [ last ] = top #NEWLINE# #UNINDENT# #UNINDENT# return m