end end tryprocedure allqueens*var ijintegerbegin for : to do [ :truex[ :- endfor : to do [ :truec[ :true endm : try( )log string('no of solutions')log int( )log ln end allqueens table twelve solutions to the eight queens problem the stable marriage problem assume that two disjoint sets and of equal size are given find set of pairs such that in and in satisfy some constrains many different criteria for such pairs existone of them is the rule called the stable marriage rule assume that is set of men and is set of women each man and each women has stated distinct preferences for their possible partners if the couples are chosen such that there exists man and woman who are not marriedbut who would both prefer each other to their actual marriage partnersthen the assignment is unstable if no such pair existsit is called stable this situation characterizes many related problems in which assignments have to be made according to preferences such asfor examplethe choice of school by studentsthe choice of recruits by different branches of the armed servicesetc the example of marriages is particularly intuitivenotehoweverthat the stated list of preferences is invariant and does not change after particular assignment has been made this assumption simplifies the problembut it also represents grave distortion of reality (called abstractionone way to search for solution is to try pairing off members of the two sets one after the other until the two sets are exhausted setting out to find all stable assignmentswe can readily sketch solution by using the program schema of allqueens as template let try(mdenote the algorithm to find partner for man mand let this search proceed in the order of the man' list of stated preferences the first version based on these assumptions isprocedure try (mman)