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.
Example:
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
Problem Comments
-
2 Comments
Christian Schröder
on 8 Aug 2023
Does the 6th test case -- h = 5, n = 3 -- count as having "agreeable dimensions"?
Josh
on 8 Aug 2023
thank you for the review @Christian, i agree that the 6th test case wasn't ideal for the problem description and have since updated the tests, that scenario might be appropriate for another iteration of the problem that i may write out
Solution Comments
Show commentsProblem Recent Solvers11
Suggested Problems
-
Get the area codes from a list of phone numbers
1053 Solvers
-
3281 Solvers
-
Test if two numbers have the same digits
243 Solvers
-
350 Solvers
-
106 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!