Wednesday, February 8, 2017

Eye to Eye

[Background: the great mathematical savant Beremiz Samir, having served the caliphate with great distinction, is offered any reward he wants by the caliph.  Beremiz asks for the hand of Sheik Iezid Abul Hamid's daughter in marriage. The caliph agrees, but only if Beremiz can solve the following puzzle.]

And so the caliph spoke: "I own five beautiful slave girls, recently purchased from a Mongol prince. Two of those young enchantresses have black eyes; the other three, blue eyes. The two with black eyes always give a truthful answer to any question, whereas the three with blue eyes are born liars and never answer with the truth. In a few moments, the five of them will be brought here, all of their faces covered by a heavy veil, which will make it impossible for you to see their faces. You must discover, with no room for error, which of them have black eyes and which blue eyes. You may question three of the five slaves, one question to each one. From the three answers, you must solve the problem and explain the precise reasoning that led you to your answer. Your questions should be quite simple ones, well within the compass of these slaves to answer."

Some moments later, watched curiously by everyone present, the five slave girls appeared in the reception hall, their faces covered with black veils, like phantoms of the desert.

"Here they are," said the emir somewhat proudly. "Two of them as I told you have black eyes and speak only the truth. The other three have blue eyes and always lie."

"What a scandal!” muttered the thin old man. “Imagine my bad luck! My uncle’s daughter has black eyes, very black—yet she lies all day long!"

His remark seemed to me out of order. It was a very serious moment, no time for jokes. Luckily, no one paid any attention to the nasty words of the impertinent old man. Beremiz realized that he had reached a decisive moment, perhaps the high point of his whole life. The problem that the caliph of Baghdad had presented him with was original and difficult and could be full of pitfalls. He was free to question three of the slave girls. But how would their replies indicate the color of their eyes? Which of them should he question? How would he know the eye colors of the two he could not question?

There was only one certainty, that the two with black eyes always spoke the truth and the other three invariably lied. But would that be enough? When Beremiz questioned them, the question had to be quite natural, well within the reach of the girl questioned. But how could he be sure of her reply, whether it was true or false? It was really very difficult indeed.

The five veiled slave girls lined up in the middle of the sumptuous hall in complete silence. The sheiks and viziers waited for the solution to this singular problem set by their king with a lively interest. The Man Who Counted approached the first slave girl on the right of the row, at the end, and asked her quietly, "What color are your eyes?"

The girl replied in a language that was apparently Chinese, a language that nobody present could understand. It made no sense to me. Hearing her, the caliph ordered that the other replies be in Arabic, simple and precise.

This unexpected setback made things more difficult for Beremiz. He had only two questions left, and the answer to his first question had been completely lost.

This did not seem to upset him, however, as he approached the second slave and asked her, "What was the reply that your companion just gave?"

The second slave answered, "She said, 'My eyes are blue.'"

That reply cleared up nothing. Had the second slave told the truth, or was she lying? And the first? Was that her real reply?

The third slave girl, in the center of the row, was questioned next by Beremiz. "What color are the eyes of those two girls I have just questioned?"

And the third girl, the last to be questioned, replied as follows: "The first girl has black eyes and the second blue eyes."
(Source: The Man Who Counted: A Collection of Mathematical Adventures by Júlio César de Mello e Souza)

How did he answer? I was able to figure out the answer before reading ahead, but the way I did it was to consider the implications of the third slave having black or blue eyes. In my opinion, Beremiz Samir's solution was even better. It hinges on the fact that all of the slaves can only ever report that they have black eyes: the black-eyed ones, because it is so, and the blue-eyed ones, because they always lie. This means the second slave is lying right off the bat. Because one thing the third slave said is true, so is the other. The first and third slaves have black eyes; the others, blue.

But, for the record, here's how it goes in the book:
Beremiz paused a moment and then calmly approached the throne, speaking as follows: "Lord of all believers, Shadow of Allah on earth, I have a solution to your problem, arrived at through strict logic. The first slave girl on the right has black eyes. The second has blue eyes. The third has black eyes, and the other two have blue eyes."

At this the five slave girls lifted their veils, uncovering smiling faces. Great sighs arose throughout the reception hall. Beremiz in his faultless intelligence had exactly determined the color of all their eyes.

"All praise to the Prophet!" cried the king. "This problem has been set to hundreds of wise men, poets, and scribes, and at last this modest Persian is the only one who has been able to solve it. How did you come by your answer? Show us how you came to be so certain of your solution."

The Man Who Counted gave the following explanation:

"When I asked the first question—what is the color of your eyes—I knew that the slave girl's answer had to be 'My eyes are black,' because if she had black eyes she would have to tell the truth, or if she had blue eyes, she would have to lie. So there could be only one reply, namely, 'My eyes are black.' I expected that answer; but when the girl replied to me in an unknown language, she helped me enormously. Claiming not to have understood, I asked the second slave girl, 'What was the reply your companion just gave?' and received the second answer—'She said: my eyes are blue.' That reply proved to me that the second girl was lying, since, as I have already shown, it could not have been the reply of the first girl. Consequently, if the second slave was lying, she had blue eyes. This was an important point, O King, in solving the problem. Of the five slave girls, there was at least one whom I had identified with mathematical certainty, namely, the second. She had lied, and so she had blue eyes."

"My third and last question I asked of the girl in the center of the row. 'What color are the eyes of those two girls I have just questioned?' She gave me the following reply: 'The first girl has black eyes and the second blue eyes.' Since I knew already that the second did have blue eyes, what conclusion was I to come to over the reply of the third girl? Very simple. The third girl was not lying, since she was confirming what I already knew, namely, that the second girl had blue eyes. Her reply also told me that the first slave girl had black eyes. Since the third girl was not lying, her words spoke the truth, and therefore she too had black eyes. From there, it was simple to deduce that the two other girls, by exclusion, had blue eyes."

2 comments:

  1. Hi! I've just finished reading the book today (can't recall if I ever finished it when I got it in 95), and I see a problem with Beremiz's solution.

    What if the 3rd slave had blue eyes? She would reply: "The first girl has BLUE eyes and the second BLACK eyes."

    In this scenario, Beremiz would still know that the first slave asked has black eyes, but now the 2nd AND 3rd would have blue eyes, leaving to chance which slave left (4th or 5th) has black eyes.

    As far as I can tell, there is a simple solution to this problem, that needs only 1 question:
    "Which of the other slaves have black eyes?"
    If there is only one slave singled out, then that one and the one who answered have black eyes.
    If there are two slaves pointed to, then the other two have black eyes and those singled out and the one who answered have blue eyes.

    Am I going crazy? Have I missed something?

    PS: Haven't looked into your blog yet, but I'll sure love it!

    ReplyDelete
    Replies
    1. The third slave can't have blue eyes because the response of the second slave has to be false. None of them can claim to have blue eyes, just as a knave of the Isle of Knights and Knaves can never claim to be a knave.

      Delete