灯下 登录
计算机科学 / SICP / 4.3.2 Examples of Nondeterministic Programs

Exercise 4.42 · 习题

Exercise 4.42: Solve the following “Liars”
puzzle (from Phillips 1934):

Five schoolgirls sat for an examination. Their parents—so they
thought—showed an undue degree of interest in the result. They therefore
agreed that, in writing home about the examination, each girl should make one
true statement and one untrue one. The following are the relevant passages
from their letters:

Betty: “Kitty was second in the examination. I was only third.”

Ethel: “You’ll be glad to hear that I was on top. Joan was second.”

Joan: “I was third, and poor old Ethel was bottom.”

Kitty: “I came out second. Mary was only fourth.”

Mary: “I was fourth. Top place was taken by Betty.”

What in fact was the order in which the five girls were placed?

练习 4.42:求解以下"说谎者"谜题(取自 Phillips 1934):

五个女生参加了一次考试。她们的父母——据她们看来——对考试结果表现出了过分的关注。于是她们商定,在写信回家汇报考试情况时,每人说一句真话和一句假话。以下是她们信件中的相关内容:

Betty:"Kitty 考了第二名。我只得了第三名。"

Ethel:"很高兴告诉你,我考了第一名。Joan 考了第二名。"

Joan:"我考了第三名,可怜的 Ethel 考了最后一名。"

Kitty:"我考了第二名。Mary 只得了第四名。"

Mary:"我考了第四名。第一名是 Betty。"

五个女生实际上的名次顺序是什么?