def spiralOrder(matrix): if not matrix: return [] return [ matrix[y][x] for x, y in spiral(True, 0, 0, len(matrix[0]), len(matrix))]
def generateMatrix(n): matrix = [[0 for _ in range(n)] for _ in range(n)] for (x, y), v in zip(spiral(True, 0, 0, n, n), count(1)): matrix[y][x] = v return matrix
def generateMatrix(n): matrix = [[0 for _ in xrange(n)] for _ in xrange(n)] for (x, y), v in izip(spiral(True, 0, 0, n, n), count(1)): matrix[y][x] = v return matrix
def spiralOrder(matrix): if not matrix: return [] return [ matrix[y][x] for x, y in spiral(True, 0, 0, len(matrix[0]), len(matrix)) ]