Reputation: 87
This is the code i have written :
print("Enter the number row and columns")
row, column = input().split()
print("Enter the rectangle size")
m, n = input().split()
Squares=row(row+1)(2*row+1)/6
print("Squares="+Squares)
Problem : Inputs are :
index values to be found out in a 3*3 matrix
The problem is from m and n how many squares of 2*2 matrix can be made in a 3*3 matrix
expected output: Squares=4
Can anyone help ?
Upvotes: 0
Views: 282
Reputation: 106455
The answer is quite simply (row - m + 1) * (column - n + 1)
.
So change:
Squares=row(row+1)(2*row+1)/6
to:
Squares = (row - m + 1) * (column - n + 1)
Upvotes: 2