422,952 Members | 2,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,952 IT Pros & Developers. It's quick & easy.

something wrong to uri 1478 solution

P: 1
I am new at python...I write this code. This is a uri problem and problem no 1478.Here the uri problem link:https://www.urionlinejudge.com.br/ju...lems/view/1478
My code:
Expand|Select|Wrap|Line Numbers
  1. while(1):
  2.     N=int(input())
  3.     if(N==0):
  4.         break
  5.  
  6.     mainlist=[]
  7.     for i in range(0,N):
  8.         sublist=[]
  9.         for j in range(0,N):
  10.             sublist.append(9)
  11.         mainlist.append(sublist)
  12.  
  13.     print(mainlist)
  14.  
  15.     a=0
  16.     b=N
  17.     c=0
  18.     d=N-1
  19.     k=1
  20.     for j in range(0,N):
  21.         for i in range(a,b):
  22.             mainlist[c][i]=i+k
  23.             mainlist[i][c]=i+k
  24.             mainlist[d][N-1-i]=i+k
  25.             mainlist[N-1-i][d]=i+k
  26.  
  27.         a+=1
  28.         b-=1
  29.         c+=1
  30.         d-=1
  31.         k-=1
  32.  
  33.     for i in range(0,N):
  34.         for j in range(0,N-1):
  35.             print(" ",mainlist[i][j],end=" ")
  36.         print(" ",mainlist[i][N-1])
  37.     print("")
but when i submit this on uri...showing something error.and couldnt found this.Please anyone help me to fine the error of my code.
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,230
Please use code tags when posting code or formatted data.

Did you try running your code to see if the output matches? Because it doesn't. Your code prints out extra stuff that it's not looking for. Specifically arrays filled with a bunch of 9s.
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.