Exercise 4.43: Use the amb evaluator to
solve the following puzzle:
Mary Ann Moore’s father has a yacht and so has each of his four friends:
Colonel Downing, Mr. Hall, Sir Barnacle Hood, and Dr. Parker. Each of the
five also has one daughter and each has named his yacht after a daughter of one
of the others. Sir Barnacle’s yacht is the Gabrielle, Mr. Moore owns the
Lorna; Mr. Hall the Rosalind. The Melissa, owned by Colonel Downing, is named
after Sir Barnacle’s daughter. Gabrielle’s father owns the yacht that is named
after Dr. Parker’s daughter. Who is Lorna’s father?
Try to write the program so that it runs efficiently (see Exercise 4.40).
Also determine how many solutions there are if we are not told that Mary Ann’s
last name is Moore.
练习 4.43:用 amb 求值器求解以下谜题:
Mary Ann Moore 的父亲有一艘游艇,他的四位朋友也各有一艘:Colonel Downing、Mr. Hall、Sir Barnacle Hood 和 Dr. Parker。这五人各有一个女儿,且每人都以其他某人的女儿来命名自己的游艇。Sir Barnacle 的游艇名为 Gabrielle,Mr. Moore 的游艇名为 Lorna,Mr. Hall 的游艇名为 Rosalind。Colonel Downing 拥有的 Melissa 号是以 Sir Barnacle 的女儿命名的。Gabrielle 的父亲拥有的游艇是以 Dr. Parker 的女儿命名的。Lorna 的父亲是谁?
尽量将程序写得高效(参见练习 4.40)。另外,如果不告知 Mary Ann 的姓是 Moore,该谜题有多少个解?