Advertisement
davide1409

croce

Dec 9th, 2019
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def croce(A,i,j):
  2. #@param A: matrix of numbers
  3. #@param i : int
  4. #@param j: int
  5. #@return bool
  6.   h = len(A) #altezza matrice
  7.   w = len(A[0]) #larghezza matrice
  8.   check = 0
  9.  
  10.   if (i-1 < 0) or (A[i][j]>A[i-1][j]):
  11.     check+=1
  12.  
  13.   if (i+1>=h) or (A[i][j]>A[i+1][j]):
  14.     check+=1
  15.  
  16.   if (j-1<0) or (A[i][j]>A[i][j-1]):
  17.     check+=1
  18.    
  19.   if (j+1>=w) or (A[i][j]>A[i][j+1]):
  20.     check+=1
  21.    
  22.   if check == 4:
  23.     return True
  24.   else:
  25.     return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement