TOPIC

Presentation error

Caiafa asked 1 year ago

Eu olhei todas as abas aqui nessa seção, mas ainda continua tendo esse erro


#https://www.urionlinejudge.com.br/judge/en/problems/view/1435

def create_matrix(dimension,n=0):
    return[[n]*dimension for i in range(dimension)]

def plus_one(matrix,dimension,start):
    row_id = start
    while row_id < dimension:
        row = matrix[row_id][start:dimension]
        row= list(map(lambda x:x+1, row))
        matrix[row_id][start:dimension] = row
        row_id +=1
    return matrix

def recursion_matrix(matrix, dimension, start=0):
    if dimension <=2:
        matrix = plus_one(matrix,dimension,start)
        return matrix,dimension+1, start-1
    else:
        matrix,new_dimension,start = recursion_matrix(matrix,dimension-1,start+1)
        matrix = plus_one(matrix,new_dimension,start)
        return matrix,new_dimension+1,start-1

def print_matrix(matrix):
    for row in matrix:
      for element in row:
          print(str(element).rjust(4,' '), end='')

      print('\n')  

dimension = 1
while (dimension !=0):
    dimension = int(input())
    matrix = create_matrix(dimension)
    matrix,_,_ = recursion_matrix(matrix,dimension)

    print_matrix(matrix)

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.