Saturday, December 3, 2011

place n queens on a chessboard

typical recursive solution where we tentatively put a queen, if this doesn't violate conditions in column i. Then continue in  submatrix i+1, i+1. Then remove the queen. the important thing is that we accumulate the intermediate result.

1 comment:

  1. An interesting question. How many N-Queens solutions are possible in an N x N board.

    More details about question

    My solution here (based on permutations)