Tagged with " depth first search"

Programming Challenge: Solve Eight Queens Puzzle by SAS

May 7, 2011 by     1 Comment     Posted under: Monthly Contest, New Technologies

Megha has kept her momentum to become the winner of the second programming challenge: Web Crawling (L1). Congratulation, Megha :) !

About web crawling, we’ve done with single page mining, and cross-page mining. The next step is to move to a single domain mining. However, to do that, we’ve got to make some preparation. That is where “Eight queens puzzle” comes from.

By definition from wikipedia,

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens attack each other. Thus, a solution requires that no two queens share the same row, column, or diagonal.

So our challenge is: Write in SAS to solve eight queens puzzle. Please follow an output format: for the example shown in the figure below, the solution is expressed as 24683175. So every solution is written as an eight-digit number: The 1st digit from the left represents the queen’s rank position in file a, the second the queen’s in file b, et cetera.

Solid white.svg a b c d e f g h Solid white.svg
8 {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} white queen {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ 8
7 {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} white queen {{{square}}} __ 7
6 {{{square}}} __ {{{square}}} __ {{{square}}} white queen {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ 6
5 {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} white queen 5
4 {{{square}}} __ {{{square}}} white queen {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ 4
3 {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} white queen {{{square}}} __ {{{square}}} __ {{{square}}} __ 3
2 {{{square}}} white queen {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ 2
1 {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} __ {{{square}}} white queen {{{square}}} __ {{{square}}} __ 1
Solid white.svg a b c d e f g h Solid white.svg

Please send your code to me. The deadline is June 1, 2011 and the prize is a $25 gift card from either Macy’s or Fry’s.

Check out the BioNews, a very handy daily recap of the latest industry news!