Problem 4. Make a checkerboard matrix
Given an integer n, make an n-by-n matrix made up of alternating ones and zeros as shown below. The a(1,1) should be 1.
Example:
Input n = 5
Output a is [1 0 1 0 1
0 1 0 1 0
1 0 1 0 1
0 1 0 1 0
1 0 1 0 1]
Solution Stats
Problem Comments
-
38 Comments
Show
35 older comments
Judith
on 19 Dec 2022
Fun problem with different solutions!
Adam Kure
on 12 Apr 2023
Nice problem, but tests 6 and 8 seem to make no sense. They use same input to the function, but expects different output, thus making it impossible to solve it.
Can someone please confirm?
Dyuman Joshi
on 12 Apr 2023
@Adam, that test case was left incomplete, as there was some problem on my end as I was updating the problem.
I have now edited the test suite and have re-scored your solution as well.
Solution Comments
Show commentsProblem Recent Solvers15899
Suggested Problems
-
The Goldbach Conjecture, Part 2
2367 Solvers
-
712 Solvers
-
5264 Solvers
-
Deleting an element in a matrix
472 Solvers
-
1802 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!