Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
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.
An interesting question. How many N-Queens solutions are possible in an N x N board.
ReplyDeleteMore details about question
http://www.codechef.com/problems/TIC04
My solution here (based on permutations)
http://www.codechef.com/viewsolution/1747911