SHARE
TWEET

Untitled

a guest Apr 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n=int(input())
  2. a=[[0]*n for i in range (n)]
  3. left=0
  4. right=0
  5. d=1
  6. for i in range (len(a)):
  7.     for j in range (len(a)):
  8.         if i==j:
  9.             left=(j-1)
  10.             right=(j+1)
  11.             while right<len(a):
  12.                 a[i][right]+=d
  13.                 right+=1
  14.                 d+=1
  15.             d=1
  16.             while left>=0:
  17.                 a[i][left]+=d
  18.                 left-=1
  19.                 d+=1
  20.             d=1
  21. for i in range (len(a)):
  22.     for j in range (len(a[i])):
  23.         a[i][j]=str(a[i][j])
  24.     print(' '.join(a[i]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top