12.4 Exercises
For exercises 13, start from the constraint model for the queens problem
given in section 12.2.4. It is available in the examples directory
as queens_ic.ecl.
 Use the search/6 predicate from the ic_search library and the
standard model for the queens problem (given below) to find ONE
solution to the 42queens problem.
With a naive search strategy this requires millions of backtracks.
Using heuristics and/or incomplete search, try to find a solution
in less than 100 backtracks!
 How many solutions does the 9queens problem have?
 Solve the "8 sticky queens problem": Assume that the queens
in neighbouring columns want to stick together as close as possible.
Minimize the sum of the vertical distances between neighbouring queens.
What is the best and what is the worst solution for this problem?
 For given N, create a list of length N whose members are numbers
between 1 and N (inclusive), which are all different (easy so far)
and satisfy the following constraint.
For each element E of the list, its successors are divided into two sets,

BiggerE: the successors which are greater than E and
 SmallerE: the successors less than E.
(Thus no successor takes the same value as E).
The cardinalities of the sets BiggerE and SmallerE differ by at most 1.  A harder version of the problem is similar.
For given N, create a list of length N whose members are numbers
between 1 and some upper bound Max (start with, say Max = N^{2}),
which are all different (easy so far)
and satisfy the following (more complex) constraint.
For each K from 1..N, call the Kth element of the list Ek.
Its successors are divided into two sets, as before:

BiggerEk: the successors which are greater than or equal to Ek + K and
 SmallerEk: the successors less than or equal to Ek  K.
(Thus no successor takes a value between EkK+1 and Ek+K1.)
The cardinalities of the sets BiggerEk and SmallerEk differ
by at most 1. What is the smallest upper bound Max for which there is a feasible solution?