[Question]
  [
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.
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
52 seconds!
```
+€ḶḂ
```
[Try it online!](https://tio.run/##y0rNyan8/1/7UdOahzu2PdzR9P//fxMA "Jelly – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 5 bytes
```
:otYT
```
Try it at [**MATL online!**](https://matl.io/?code=%3AotYT&inputs=4&version=20.2.1)
### Explanation
Consider input `4` as an example.
```
:    % Implicit input, n. Push range [1 2 ... n]
     %   STACK: [1 2 3 4]
o    % Parity, element-wise
     %   STACK: [1 0 1 0]
t    % Duplicate
     %   STACK: [1 0 1 0], [1 0 1 0]
YT   % Toeplitz matrix with two inputs. Implicit display
     %   STACK: [1 0 1 0;
     %           0 1 0 1;
     %           1 0 1 0;
     5           0 1 0 1]
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 bytes
```
ÆÇ+X v
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.5&code=xscrWCB2&input=NSAtUQ==) (Uses `-Q` flag for easier visualisation)
### Explanation
```
 Æ   Ç   +X v
UoX{UoZ{Z+X v}}  // Ungolfed
                 // Implicit: U = input number
UoX{          }  // Create the range [0...U), and map each item X to
    UoZ{     }   //   create the range [0...U), and map each item Z to
        Z+X      //     Z + X
            v    //     is divisible by 2.
                 // Implicit: output result of last expression
```
An interesting thing to note is that `v` is *not* a "divisible by 2" built-in. Instead, it's a "divisible by X" built-in. However, unlike most golfing languages, Japt's functions do not have fixed arity (they can accept any number of right-arguments). When given 0 right-arguments, `v` assumes you wanted `2`, and so acts exactly like it was given `2` instead of nothing.
[Answer]
# [V](https://github.com/DJMcMayhem/V), ~~16~~, 15 bytes
```
Ài10À­ñÙxñÎÀlD
```
[Try it online!](https://tio.run/##K/v//3BDpqGB9OGGQ2sPbzw8swJI9B1uyHH5//@/OQA "V – Try It Online")
Hexdump:
```
00000000: c069 3130 1bc0 adf1 d978 f1ce c06c 44    .i10.....x...lD
```
[Answer]
## [Haskell](https://www.haskell.org/), ~~50~~ ~~41~~ ~~39~~ 38 bytes
*Thanks to nimi and xnor for helping to shave off a total of ~~9~~ 10 bytes*
```
f n=r[r"10",r"01"]where r=take n.cycle
```
Alternately, for one byte more:
```
(!)=(.cycle).take
f n=n![n!"10",n!"01"]
```
or:
```
r=flip take.cycle
f n=r[r"10"n,r"01"n]n
```
Probably suboptimal, but a clean, straightforward approach.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 8 bytes
```
~2|⍳∘.+⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///3/FR24Q6o5pHvZsfdczQ0wbSQLFDK4C0CQA "APL (Dyalog Unicode) – Try It Online")
### Explanation
Let's call the argument `n`.
```
⍳∘.+⍳
```
This creates a matrix
```
1+1 1+2 1+2 .. 1+n
2+1 2+2 2+3 .. 2+n
...
n+1 n+2 n+3 .. n+n
```
Then `2|` takes modulo 2 of the matrix (it vectorises) after which `~` takes the NOT of the result.
[Answer]
## JavaScript ES6, ~~55~~ ~~54~~ ~~51~~ 46 bytes
*Saved 1 byte thanks to @Neil*
*Saved 2 bytes thanks to @Arnauld*
```
n=>[...Array(n)].map((_,i,a)=>a.map(_=>++i&1))
```
[Try it online!](https://vihan.org/p/tio/?l=javascript-node&p=y0ktUUizVciztYvW09NzLCpKrNTI04zVy00s0NCI18nUSdS0tUuEcbOAnLpM7Sw1Q01NLq7k/Lzi/JxUvZz8dI00DaCQNZqQEaaQMaaQCVDoPwA)
This outputs as an array of arrays. JavaScript ranges are pretty unweildy but I use `[...Array(n)]` which generates an array of size `n`
[Answer]
## Mathematica, 25 bytes
```
1-Plus~Array~{#,#}~Mod~2&
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~33~~ 30 bytes
```
.+
$*
1
$_¶
11
10
T`10`01`¶.+¶
```
[Try it online!](https://tio.run/##K0otycxL/P9fT5tLRYvLkEsl/tA2LkNDLkMDrpAEQ4MEA8OEQ9v0tA9t@//fFAA "Retina – Try It Online") Explanation: The first stage converts the input to unary using `1`s (conveniently!) while the second stage turns the value into a square. The third stage inverts alternate bits on each row while the last stage inverts bits on alternate rows. Edit: Saved 3 bytes thanks to @MartinEnder.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~9~~ 7 bytes
-2 bytes thanks to Emigna
```
LDÈD_‚è
```
[Try it online!](https://tio.run/##MzBNTDJM/f/fx@Vwh0v8o4ZZh1f8/28MAA "05AB1E – Try It Online")
### Explanation
```
LDÈD_‚sè» Argument n
LD        Push list [1 .. n], duplicate
  ÈD      Map is_uneven, duplicate
    _     Negate boolean (0 -> 1, 1 -> 0)
     ‚    List of top two elements of stack
      è   For each i in [1 .. n], get element at i in above created list
          In 05AB1E the element at index 2 in [0, 1] is 0 again
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 7 bytes
```
:t!+2\~
```
[Try it online!](https://tio.run/##y00syfn/36pEUdsopu7/fxMA "MATL – Try It Online")
**Explanation:**
```
         % Implicit input (n)
:        % Range from 1-n, [1,2,3]
 t       % Duplicate, [1,2,3], [1,2,3]
  !      % Transpose, [1,2,3], [1;2;3]
   +     % Add        [2,3,4; 3,4,5; 4,5,6]
    2    % Push 2     [2,3,4; 3,4,5; 4,5,6], 2
     \   % Modulus    [0,1,0; 1,0,1; 0,1,0]
      ~  % Negate     [1,0,1; 0,1,0; 1,0,1]
```
Note: I started solving this in MATL *after* I posted the challenge.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 15 bytes
```
^₂⟦₁%₂ᵐ;?ḍ₎pᵐ.\
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/P@5RU9Oj@cseNTWqAlkPt06wtn@4o/dRU18BkK0X8/@/6f8oAA "Brachylog – Try It Online")
### Explanation
```
Example Input: 4
^₂               Square:                            16
  ⟦₁             1-indexed Range:                   [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    %₂ᵐ          Map Mod 2:                         [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0]
       ;?ḍ₎      Input-Chotomize:                   [[1,0,1,0],[0,1,0,1],[1,0,1,0],[0,1,0,1]]
           pᵐ.   Map permute such that..
             .\  ..the output is its own transpose: [[1,0,1,0],[0,1,0,1],[1,0,1,0],[0,1,0,1]]
```
[Answer]
## Clojure, 36 bytes
```
#(take %(partition % 1(cycle[1 0])))
```
Yay, right tool for the job.
[Answer]
# [J](http://jsoftware.com/), 9 bytes
```
<0&=$&1 0
```
[Try it online!](https://tio.run/##y/r/P03B1krBxkDNVkXNUMGAiys1OSNfIU3B5P9/AA "J – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~80~~ 77 bytes
-3 bytes thanks to Kevin Cruijssen
```
j->{String s="1";for(int i=1;i<j*j;s+=i++/j+i%j&1)s+=1>i%j?"\n":"";return s;}
```
[Try it online!](https://tio.run/##LU69asMwEJ6dpzgELXbdqBgyVbG7FTp0yth2UB3ZnKqchHQKhOBndwXJdN8/Z/VZb30wZI9/a8i/DkcYnU4JPjXSdVPdtcSayzl7PMKpOPWBI9L89QM6zqkpwcqWKZkZnZwyjYye5Psd7D@IzWziM9xqA0zQr3Y7XG8cUi86oSYfayQG7DuFe/tkVWp7bNsX2@KDfeyaQruhwDfxTeJVCBUN50iQ1LJWlSpPHC6JzUn6zDKUZXZUT1KH4C71rmlKYtks6z8 "Java (OpenJDK 8) – Try It Online")
Oh look, a semi-reasonable length java answer, with lots of fun operators. 
lambda which takes an int and returns a String. Works by using the row number and column number using / and % to determine which value it should be, mod 2;
Ungolfed:
```
j->{
    String s="1";
    for(int i=1; i<j*j; s+= i++/j + i%j&1 )
        s+= 1>i%j ? "\n" : "";
    return s;
}
```
[Answer]
# [Nekomata](https://github.com/AlephAlpha/Nekomata), 5 bytes
```
ᵒ+→2%
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70iLzU7PzexJHFZtJJurlLsgqWlJWm6Fisfbp2k_ahtkpHqkuKk5GKo6ILlhlxGXMZcJhAuAA)
```
ᵒ+→2%
ᵒ+       Create an (input x input) matrix where the element at (i,j) is i+j
  →      Increment
   2%    Mod 2
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 19 bytes
```
⟦₁Rg;Rz{z{++₁%₂}ᵐ}ᵐ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//9H8ZY@aGoPSrYOqqquqtbWBHNVHTU21D7dOAOH//03@RwEA "Brachylog – Try It Online")
[Answer]
# Charcoal, 8 bytes
```
ＵＯＮ10¶01
```
[Try it online!](https://tio.run/##ARwA4/9jaGFyY29hbP//77y177yv77yuMTDCtjAx//81 "Charcoal – Try It Online") Explanation: This roughly translates to the following verbose code (unfortunately the deverbosifier is currently appending an unnecessary separator):
```
Oblong(InputNumber(), "10\n01");
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 9 bytes
```
VQm%+hdN2
```
[Try this!](https://pyth.herokuapp.com/?code=VQm%25%2BhdN2&input=10&debug=0)
another 9 byte solution:
```
mm%+hdk2Q
```
[Try it!](https://pyth.herokuapp.com/?code=mm%25%2Bhdk2Q&input=10&debug=0)
[Answer]
# [///](https://esolangs.org/wiki////), 87 bytes + input
```
/V/\\\///D/VV//*/k#D#k/k#D&k/k&DVk/k\D/SD/#/r
DSkk/10DSk/1D&/V#rV#0r;VV0;VVV1;V\D/r/S/&[unary input in asterisks]
```
[Try it online!](https://tio.run/##FcohCsAwEERR32ssRNT8RMfuDQKjYioKhVQl9yfdDswbM@u91nOvvRG9d8CR4GSY2/hNYXKF3WmOMQ9vY1ByDMUTsinLs0o5qlIV10kjnZG9Pw "/// – Try It Online") (input for 4)
## Unary input in `1`s, 95 bytes + input
```
/V/\\\///D/VV//&1/k#&D&|D/#k/k#D&k/k&DVk/k\D/SD/#/r
DSkk/10DSk/1D&/V#rV#0r;VV0;VVV1;V\D/r/S/&&[unary input in ones]|
```
[Try it online!](https://tio.run/##LYoxCsQwEAP7@4Zh2/HWafcHBlVuUgQOnMpu83dniwg0EkLrPtf/Wnsjeu9AIIE5o1jYE5SRNSxpoWQPWq7MX7Qx8JqBh6EyVeo8pJqWH8rrpGHmn569Xw "/// – Try It Online") (input for 8)
### How does this work?
* `V` and `D` are to golf `\/` and `//` respectively.
* `/*/k#/` and `/&1/k#&//&|//` separate the input into the equivalent of `'k#'*len(input())`
* `/#k//k#//&k/k&//\/k/k\//` move all the `k`s to the `/r/S/` block
* `S`s are just used to pad instances where `k`s come after `/`s so that they don't get moved elsewhere, and the `S`s are then removed
* `#`s are then turned into `r\n`s
* The string of `k`s is turned into an alternating `1010...` string
* The `r\n`s are turned into `1010...\n`s
* Every pair of `1010...\n1010\n` is turned into `1010...\01010...;\n`
* Either `0;` or `1;` are trimmed off (because the `01010...` string is too long by 1)
[Answer]
# Mathematica, 23 bytes
```
ToeplitzMatrix@#~Mod~2&
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 24 bytes
```
@(n)~mod((a=(1:n))+a',2)
```
[Try it online!](https://tio.run/##y08uSSxL/Z@mYKugp6f330EjT7MuNz9FQyPRVsPQKk9TUztRXcdI83@ahonmfwA "Octave – Try It Online")
---
Or the same length:
```
@(n)mod(toeplitz(1:n),2)
```
[Try it online!](https://tio.run/##y08uSSxL/Z@mYKugp6f330EjTzM3P0WjJD@1ICezpErD0CpPU8dI83@ahonmfwA "Octave – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~38~~ 37 bytes
```
n=scan();(matrix(1:n,n,n,T)+1:n-1)%%2
```
[Try it online!](https://tio.run/##K/r/P8@2ODkxT0PTWiM3saQos0LD0CpPBwRDNLWBTF1DTVVVo/8m/wE "R – Try It Online")
-1 byte thanks to Giuseppe
Takes advantage of R's recycling rules, firstly when creating the matrix, and secondly when adding 0:(n-1) to that matrix.
[Answer]
## Swi-Prolog, 142 bytes.
```
t(0,1).
t(1,0).
r([],_).
r([H|T],H):-t(H,I),r(T,I).
f([],_,_).
f([H|T],N,B):-length(H,N),r(H,B),t(B,D),f(T,N,D).
c(N,C):-length(C,N),f(C,N,1).
```
Try online - <http://swish.swi-prolog.org/p/BuabBPrw.pl>
It outputs a nested list, so the rules say:
* `t()` is a toggle, it makes the 0 -> 1 and 1 -> 0.
* `r()` succeeds for an individual row, which is a recursive check down a row that it is alternate ones and zeros only.
* `f()` recursively checks all the rows, that they are the right length, that they are valid rows with `r()` and that each row starts with a differing 0/1.
* `c(N,C)` says that C is a valid checkerboard of size N if the number of rows (nested lists) is N, and the helper f succeeds.
Test Cases:
[![enter image description here](https://i.stack.imgur.com/8AH2d.png)](https://i.stack.imgur.com/8AH2d.png)
[Answer]
# C, ~~69~~ ~~67~~ 63 bytes
*Thanks to @Kevin Cruijssen for saving two bytes and @ceilingcat for saving four bytes!*
```
i,j;f(n){for(i=n;i--;puts(""))for(j=n;j;)printf("%d",j--+i&1);}
```
[Try it online!](https://tio.run/##Zcy7CoAwDIXh3aeQgpKgGbxswYeRSiUFq3iZxGevEXTyTD/fcCyN1sYopWcHAU83ryBdYCHi5dg3MAbxQa/oGZdVwu7AZIMpPVEheYV8RcV06iUAJmeS6hyofwf8Uv2n5k@t1hVv)
[Answer]
# [Arturo](https://arturo-lang.io), ~~39~~ 36 bytes
```
$[n][map..1n'x->map..1n'y->%x+y+1 2]
```
[Try it](http://arturo-lang.io/playground?MhWhVe)
-3 thanks to alephalpha's simpler method
Prettified and rearranged for clarity:
```
$[n][                     ; a function taking an argument n
    map 1..n 'x ->        ; map over 1..n, assign current elt to x
        map 1..n 'y ->    ; map over 1..n again, assign current elt to y
            (x+y+1)%2     ; what it looks like
]                         ; end function
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
ʁ∷:v=
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLKgeKItzp2PSIsIiIsIjQiXQ==)
*-3 thanks to @lyxal*   
*-1 thanks to @emanresuA*
#### Explanation
```
ʁ∷:v=    implicit input
ʁ        range(input)
 ∷       mod 2
  :      duplicate
   v=    equals, vectorised over the top list
         (generates a nested list)
```
Old:
```
ɾ∷ẋ⁽†ẇ    implicit input
ɾ         range(1, input+1)
 ∷        mod 2
  ẋ       repeated input times
     ẇ    apply to every 2nd item:
   ⁽†     vectorised not
```
```
ʁ:∷:†$"$İ    implicit input
ʁ:           range, duplicate
  ∷:         mod 2, duplicate
    †        vectorised not
     $"      swap and pair
       $İ    swap and index in
```
[Answer]
# TI-Basic, ~~30~~ 29 bytes
```
identity(Ans→[A]
Fill(1,[A]
cumSum([A]
2fPart(.5(Ans+Ansᵀ+[A]
```
Takes input in `Ans`.  
-1 byte thanks to [MarcMush](https://codegolf.stackexchange.com/users/98541/marcmush)
[Answer]
# [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 19 bytes
```
[:|?[b|?(a+c+1)%2';
```
## Explanation
```
[:|         FOR a = 1 to b (b is read from cmd line)
?           PRINT - linsert a linebreak in the output
[b|         FOR c = 1 to b
?(a+c+1)%2  PRINT a=c=1 modulo 2 (giving us the 1's and 0's
';            PRINT is followed b a literal semi-colon, suppressing newlines and 
              tabs. Printing numbers in QBasic adds one space automatically.
```
[Answer]
# [PHP](https://php.net/), 56 bytes
Output as string
```
for(;$i<$argn**2;)echo++$i%2^$n&1,$i%$argn?"":"
".!++$n;
```
[Try it online!](https://tio.run/##K8go@G9jX5BRwKWSWJSeZ6tkomT9Py2/SMNaJdMGLKSlZWStmZqcka@trZKpahSnkqdmqANkgSXtlZSslLiU9BSBknnW//9/zcvXTU5MzkgFAA "PHP – Try It Online")
# [PHP](https://php.net/), 66 bytes
Output as 2 D array
```
for(;$i<$argn**2;$i%$argn?:++$n)$r[+$n][]=++$i%2^$n&1;print_r($r);
```
[Try it online!](https://tio.run/##K8go@G9jX5BRwKWSWJSeZ6tkomT9Py2/SMNaJdMGLKSlZQRkq4LZ9lba2ip5mipF0UAqNjrWFsjNVDWKU8lTM7QuKMrMK4kv0lAp0rT@//9rXr5ucmJyRioA "PHP – Try It Online")
]