# 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

725

832

1005000

• So the Camel is to the Rook what the King is to the Queen? I.e. can only move orthogonally, and only one step at a time. – Adám Oct 2 '17 at 8:32
• @SashaR May I rewrite your question as a proper code golf challenge? – Adám Oct 2 '17 at 9:09
• Sure! That way I can also see how to word coding related questions in future – Sasha R Oct 2 '17 at 9:10
• As a new user of this site, you've been very lucky this time. A lot of (off-topic) programming questions on this site has been permanently closed and downvoted, not edited as a challenge and upvoted like this one. As other people already explained, this site is for programming competitions only, not for asking homework. You can use the sandbox (at codegolf.meta.stackexchange.com/questions/2140/… ) before posting a challenge to avoid common mistakes next time; and note that most users on this site, as you have seen, use "unreadable" languages. – user202729 Oct 2 '17 at 14:52
• This question is pretty confusing in that the Camel is already the standard fairy chess name for a piece like a knight that makes longer jumps and the piece you describe already has a fairy chess name: Wazir. – Mark S. Oct 3 '17 at 11:26

# Cubically, 12 bytes

$:*FDF'+8/0%  Try it online! Personally I don't see any point with using language features newer than the challenge to get less bytes, because you mostly compete with yourself (almost always there are at most one answer/language/challenge), but I still updated, by MDXF's suggestion. : defaults to :7 is a good idea anyway. Explanation: $:*7FDF'+8/0%

Explanation:

• $ duplicate top of stack • * multiply • 1 push 1 • + add • 2 push 2 • / divide False only has 32-bit integers. # Haskell, 18 bytes w n=ceiling(n*n/2) Run as: main = print$ w n

Where n is the input number.

# x86 machine code, 6 bytes

Takes its argument in eax register, returns also there.

f7 e0   mul eax
40      inc eax
d1 e8   shr eax,1
c3      ret


# Bash, 18 bytes

echo $[$1*\$1+1>>1]


Try it online

# Excel, 15 bytes

=ROUND(A1^2/2,)


Because we are dividing by 2, we can safely replace CEILING with ROUND, saving 3 bytes.

=CEILING(A1^2/2,1)


# JavaScript (ES8), 16 bytes

x=>(h=x*x/2)+h%1
x=>                  // arrow function
(h=x*x/2)         // dictionarying
+h%1     // Math.ceil function