Sample Program
The following is a Pascal program by Niklaus Wirth. It finds one solution to the eight queens problem.
program eightqueen1(output); var i : integer; q : boolean; a : array of boolean; b : array of boolean; c : array of boolean; x : array of integer; procedure try( i : integer; var q : boolean); var j : integer; begin j := 0; repeat j := j + 1; q := false; if a and b and c then begin x := j; a := false; b := false; c := false; if i < 8 then begin try( i + 1, q); if not q then begin a := true; b := true; c := true; end end else q := true end until q or (j = 8); end; begin for i := 1 to 8 do a := true; for i := 2 to 16 do b := true; for i := -7 to 7 do c := true; try( 1, q); if q then for i := 1 to 8 do write( x:4); writeln end.Read more about this topic: Eight Queens Puzzle
Famous quotes containing the words sample and/or program:
“As a rule they will refuse even to sample a foreign dish, they regard such things as garlic and olive oil with disgust, life is unliveable to them unless they have tea and puddings.”
—George Orwell (19031950)
“Resorts advertised for waitresses, specifying that they must appear in short clothes or no engagement. Below a Gospel Guide column headed, Where our Local Divines Will Hang Out Tomorrow, was an account of spirited gun play at the Bon Ton. In Jeff Winneys California Concert Hall, patrons bucked the tiger under the watchful eye of Kitty Crawhurst, popular lady gambler.”
—Administration in the State of Colo, U.S. public relief program (1935-1943)