<qiyuangong>059_Spiral_Matrix_II_1.py
def generateMatrix( n):
    res = [[0] * n for _ in range(n)]
    pos = [0, 0]
    move = (0, 1)
    for index in range(1, n * n + 1):
        res[pos[0]][pos[1]] = index
        if res[(pos[0] + move[0]) % n][(pos[1] + move[1]) % n] > 0:
            move = (move[1], -1 * move[0])
        pos[0] = pos[0] + move[0]
        pos[1] = pos[1] + move[1]
    return res
def sample_funcname ( var_0 ) :
    var_4 = [ [ 0 ] * var_0 for var_2 in range ( var_0 ) ]
    var_5 = [ 0 , 0 ]
    var_7 = ( 0 , 1 )
    for var_8 in range ( 1 , var_0 * var_0 + 1 ) :
        var_4 [ var_5 [ 0 ] ] [ var_5 [ 1 ] ] = var_8
        if var_4 [ ( var_5 [ 0 ] + var_7 [ 0 ] ) % var_0 ] [ ( var_5 [ 1 ] + var_7 [ 1 ] ) % var_0 ] > 0 :
            var_7 = ( var_7 [ 1 ] , - 1 * var_7 [ 0 ] )
        var_5 [ 0 ] = var_5 [ 0 ] + var_7 [ 0 ]
        var_5 [ 1 ] = var_5 [ 1 ] + var_7 [ 1 ]
    return var_4
