begin repeat inc( )until ( or ( [jb[ +jc[ - + ])eos :( end nextprocedure firstbegin eos :falsej :- next end firstbegin if then firstwhile ~eos ~canbedone(ijdo next enddone :~eos else done :true end end tryprocedure canbedone (ijinteger)boolean(*solution can be completed with -th queen in -th row*var donebooleanbegin [ :ja[ :falseb[ + :falsec[ - + :falsetry( + done)if ~done then [ :- [ :trueb[ + :truec[ - + :true endreturn done end canbedoneprocedure queens*var donebooleanijinteger(*uses global writer *begin for : to do [ :truex[ :- endfor : to do [ :truec[ :true endtry( done)if done then for : to do texts writeint(wx[ ] endtexts writeln(wend end queens before we abandon the context of the chess boardthe eight queens example is to serve as an illustration of an important extension of the trial-and-error algorithm the extension is -in general terms -to find not only onebut all solutions to posed problem the extension is easily accommodated we are to recall the fact that the generation of candidates must progress in systematic manner that guarantees no candidate is generated more than once this property of the algorithm corresponds to search of the candidate tree in systematic fashion in which every node is visited exactly once it allows -once solution is found and duly recorded -merely to proceed to the next candidate delivered by the systematic selection process the modification is formally accomplished by carrying the procedure function canbedone from the loop' guard into its body and substituting the