Problem 58822. Make a "better" checkerboard matrix

This problem seeks to expand the task in Cody Problem 4 by allowing for the creation of checkerboard matrices that can be rectangular and have squares of 0s and 1s that are larger than a single element, 1x1 (i.e. 2x2, 3x3, etc).
The result is a rectangular checkerboard where the scale of the squares relative to the board can be manipulated.
For this problem, the given values are height (h), width (w), and size of squares (n), and the first square should be 1s.
h = 6
w = 4
n = 2
solution =
1 1 0 0
1 1 0 0
0 0 1 1
0 0 1 1
1 1 0 0
1 1 0 0
Note, it is possible for there to be conflicts between the dimensions of the checkerboard and the size of the squares. For example, the size of the squares must be smaller than both the height and width dimensions (n<height && n<width). There are other possibilities for dimensional conflicts as well. For the sake of this problem, the test suite values/dimensions will be agreeable; in the future, there will be another problem for handling the challenge of disagreeable dimensions.
*** This exercise has applications for image manipulation as the resulting checkerboard matrix can be used for image operations like masking and filtering. The height and width values translate to the pixel height and width of an image and square size (n) can be interpreted as a block or grain size. Another reintepretation of this problem in comparison to the simpler checkerboard matrix problem is that the solution to this problem produces checkerboard matrices of variable resolution.

Solution Stats

85.0% Correct | 15.0% Incorrect
Last Solution submitted on Dec 26, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers11

Suggested Problems

More from this Author3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!