26
2
Take a positive integer n as input, and output a n-by-n checkerboard matrix consisting of 1 and 0.
The top left digit should always be 1.
Test cases:
n = 1
1
n = 2
1 0
0 1
n = 3
1 0 1
0 1 0
1 0 1
n = 4
1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
Input and output formats are optional. Outputting the matrix as a list of lists is accepted.
Is a list of strings OK? – xnor – 2017-06-15T17:52:45.980
Yes, that's OK. – Stewie Griffin – 2017-06-15T17:53:49.607
1Related. – beaker – 2017-06-15T18:51:31.137
2Your examples show spaces between numbers on the same row, is that required, so as to look more like a square? – BradC – 2017-06-15T19:09:09.797
@BradC it's not required. The first approach here is valid.
– Stewie Griffin – 2017-06-15T20:19:29.803Can we take the input in unary if our language doesn't have the concept of a number? (e.g.
####
for input 4) – Conor O'Brien – 2017-06-15T20:26:27.773https://oeis.org/A100241 has all of the binary representations of this. Dunno how I'd even begin to use it though lol. – Magic Octopus Urn – 2017-06-16T20:40:27.217