Problem Statement:
You need to find all possible solutions to place eight queens on a chess board - Condition is no two queens should be able to collide.
Note: Queen can move diagonally or linearly to any length.
2) Now you want to place queens on 8 rows one in each row( one queeen per row :part of queens scope)
3) so each can be placed in any of 8 columns of each row.
4) when you place each one check it is not hitting any previously positioned queen.
5) Rest try to understand the code.
improve:
Int can be replaced with tiny int. (one byte can represent 8 possibilities)
This is a processor intesive and memory conservative algorithm.
Bad: hardcoded 8 alla across.
N queens on NXN square will be good problem to solve.
2008-07-29 03:39
This blog is frozen. No new comments or edits allowed.
Here are details of problem .
1) imagine rows 1,2,3,4,5,6,7,8
2) Now you want to place queens on 8 rows one in each row( one queeen per row :part of queens scope)
3) so each can be placed in any of 8 columns of each row.
4) when you place each one check it is not hitting any previously positioned queen.
5) Rest try to understand the code.
improve: Int can be replaced with tiny int. (one byte can represent 8 possibilities) This is a processor intesive and memory conservative algorithm. Bad: hardcoded 8 alla across. N queens on NXN square will be good problem to solve.