Manuals/calci/NQUEENS

Revision as of 15:20, 26 July 2017 by Devika (talk | contribs) (Created page with "<div style="font-size:30px">'''NQUEENS (GridSize)'''</div><br/> *<math>GridSize</math> is any positive integer. ==Description== *This functions creates the N-queens puzzle. *...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
NQUEENS (GridSize)


  • is any positive integer.

Description

  • This functions creates the N-queens puzzle.
  • In  ,   is the size of the row and columns.
  • Generally eight queens puzzle is the problem of placing eight chess queens on an 8x8 chessboard so that no two queens attack each other.
  • Thus, a solution requires that no two queens share the same row, column or diagonal.
  • The eight queens puzzle is a great example of the more general N Queens problem of placing N non attacking queens on an nxn chessboard where solutions exist for all natural numbers n with the exception of n=2 and n=3.
  • This function will return the result as "0" when the value of the Grid size is 2 or 3.
  • Also this will return as Error when the parameter value is non positive integer.

Examples

1. NQUEENS(4) 1 |_|Q|_|_| |_|_|_|Q| |Q|_|_|_| |_|_|Q|_|

2 |_|_|Q|_| |Q|_|_|_| |_|_|_|Q| |_|Q|_|_|

2 Solutions