Given an $ n\times n$ chessboard.
a) Find the number of rectangles on the chessboard.
b) Assume there exists an $ r\times r$ square (label $ B$) with $ r<n$ which is located on the upper left corner of the board. Define "inner border" of $ A$ as the border of $ A$ which is not the border of the chessboard. How many rectangles in $ B$ that touch exactly one inner border of $ B$?
(a) The number of rectangles is $ \binom{n+1}{2} ^2$.
(b) From the question, it is not clear if the rectangle is allowed to touch one of the borders of the chessboard in addition to it touching the inner border of $ B$. The number of rectangles that touch exactly one of the inner borders is $ \binom{r+1}{2} ^2 - \binom{r}{1} ^2$(assuming the rectangle is allowed to touch the border of the chessboard). If the rectangle is not allowed to touch the border of the chessboard, then the answer is $ \binom{r}{2} ^2 - \binom{r-1}{1} ^2$.