Given the size of board (n) and the position of the queen (r,c) how can we calculate the total number of squares which can be controlled by the queen?


closed as off-topic by elias, Glorfindel, user58, Beastly Gerbil, Rubio Jan 29 '17 at 22:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is off-topic as it appears to be a mathematics problem, as opposed to a mathematical puzzle. For more info, see "Are math-textbook-style problems on topic?" on meta." – elias, Glorfindel, Beastly Gerbil, Rubio
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    $\begingroup$ You can count them! :D $\endgroup$ – boboquack Jan 29 '17 at 8:29

Assuming the queen controls its own square and 0-based indexing, we have:

  • $1$ - its own square
  • $2n-2$ - the rows and columns without its own square
  • $n-1-|r+c-n+1|$ - the number of squares on one diagonal
  • $n-1-|r-c|$ - the number of squares on the other diagonal

Add them all up and we have:



Not the answer you're looking for? Browse other questions tagged or ask your own question.