Advertisement
viligen

2x2_identical_squares_in_matrix

Jan 21st, 2022
803
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rows, cols = [int(n) for n in input().split()]
  2.  
  3. matrix = [input().split() for i in range(rows)]
  4.  
  5. identical_squares = 0
  6.  
  7. for i in range(rows - 1):
  8.     for j in range(len(matrix[i])-1):
  9.         current_symbol = matrix[i][j]
  10.         if matrix[i][j+1] == current_symbol and matrix[i+1][j] == current_symbol and matrix[i+1][j+1] == current_symbol:
  11.             identical_squares += 1
  12.  
  13. print(identical_squares)
  14.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement