How many Wazirs can be placed on an N×N Chessboard? Suppose a new fairy chess piece named the Wazir is introduced to chess. Wazirs can move from a position (x, y) to:
 (x+1, y)
 (x, y+1)
 (x-1, y)
 (x, y-1)
That is, they move orthogonally like the rook, but only one step at a time like the king. How many such wazirs can be placed on an N×N chessboard so that no two wazirs can attack each other?
 On a 1×1 board, there can be only 1 such piece.
 On a 2×2 board, there can be 2 such pieces.
 On a 3×3 board, there can be 5 such pieces.
Given N, return the number of wazirs that can be placed on an N×N chessboard.
This is OEIS sequence A000982.
More test cases
7 → 25
8 → 32
100 → 5000
Whitespace, 45 bytes

  &#32;
&#9;
&#9;&#9;  &#32;
&#9;&#9;&#9;&#32;
 &#9; &#32;
   &#9;
&#9;      &#9;&#32;
&#9; &#9; &#9;
 &#9;


Try it online!

By the way, here is a proof that the ⌈n²/2⌉ formula is correct.


We can always place at least ⌈n²/2⌉ wazirs: just lay them out in a checkerboard pattern! Assuming the top-left tile is white, there are ⌈n²/2⌉ white tiles and ⌊n²/2⌋ black tiles on the n × n board. And if we place wazirs on the white tiles, no two of them are attacking each other, as every wazir only “sees” black tiles.

Here’s how we place 13 wazirs on a 5 × 5 board (each W is a wazir).

　　　　　　　　　　
We can’t do any better: let’s arbitrarily tile the checkerboard with 2 × 1 domino pieces, optionally using a 1 × 1 piece for the final corner of an odd-length chessboard, like so:

　　　　　　　　　　

We need ⌈n²/2⌉ dominoes to cover the chessboard. Clearly, putting two wazirs on one domino makes it so that they can attack one another! So each domino can only contain at most one wazir, meaning we can’t possibly place more than ⌈n²/2⌉ wazirs on the board.