From a standard 8x8 chessboard the squares
a1 and g8 were removed.
Evaluate the total numbers of squares created
by the horizontal and vertical lines of the distorted chessboard.
Count all possible sizes from 1x1 to 7x7.
clc,clearvars
board=zeros(8);
board(8,1)=1; board(1,7)=1;
ct=zeros(1,8);
for n=1:7
block=zeros(n);
for stRow=1:9-n
for stCol=1:9-n
if isequal(board(stRow:stRow+n-1,stCol:stCol+n-1),block)
ct(n)=ct(n)+1;
end
end
end
end
ct
sum(ct)
finds the counts for each size from 1 to 7, and the final answer is that there are a sum of 183 squares of these varied sizes.
From size 1 through 8:
ct =
62 46 33 22 13 6 1 0
Total:
ans =
183
|
Posted by Charlie
on 2023-09-05 12:51:43 |