Farm dimensions

Here is a question I was given during an interview a few years ago.

There was a farmer who had two daughters. One day he was considering giving his farm to his girls. He took his first daughter, Danielle, aside and told her in strictest confidence the area of the farm. He then took his second daughter, Tammy, aside and told her in strictest confidence the perimeter of the farm. He also told both girls together that the farm was a rectangle, that the perimeter of the farm did not exceed 80 miles and that each side of the farm was not less than two miles in length, and that all measurements were in whole miles. He then promised them that if they could tell him the dimensions of the farm without revealing to each other what he had told them in confidence, in that case he would give them the farm.

The conversation between the two girls went as follows:

Danielle said, "I don't know what the dimensions of the farm are."

Tammy responded, "I knew you were going to say that Danielle!"

Then Danielle said, "Well, I still don't know what the dimensions are!"

So Tammy said, "Well, I know what the dimensions are now!"

And Danielle concluded the conversation by saying, "Then I know what the dimensions are too!"

There was no other conversation between the girls. They went to their father, told him the dimensions of the farm, and their father kept his word and gave them the farm.

PS: Even if they do not know the value, each girl knows what information have been released to her sister. (Tammy knows that Danielle knows the area and Danielle knows that Tammy knows the perimeter.)

• I like it, it resembles the "3 impossibly intelligent mathematicians" problem, but it is doable with pen and paper Feb 12, 2015 at 15:43

In other words, we are looking for two positive integers $x$ and $y$ with $x\ge2$, $y\ge2$ and $4\le x+y\le40$ that fit with the conversation. Let us denote the sum $s=x+y$ and the product $p=xy$.

(1) Danielle's first statement "I don't know what the dimensions of the farm are" gives the following information on the product:

• $p$ is not the product of (exactly) two primes $p=ab$; otherwise Danielle would immediately deduce that $\{x,y\}=\{a,b\}$.
• $p$ does not have any prime factor $f\ge20$; otherwise Danielle would deduce $\{x,y\}=\{f,p/f\}$.

(2) Tammy responded, "I knew you were going to say that Danielle!" This means that for any possible way of writing $s$ as the sum of two summands $z$ and $s-z$, the corresponding product does not allow Danielle to deduce $x$ and $y$. Equivalently, for any integer $z$ with $2\le z\le s/2$, the corresponding product $z\cdot(s-z)$ must be of the form as excluded in (1). This excludes most possible values for $s$:

• $25\le s\le 40$: for $z=23$, the product $z\cdot(s-z)$ has been excluded.
• $4\le s\le 24$, and $s$ even: Then $s$ can be written as the sum of two primes $a$ and $b$ (as a special case of Goldbach's conjecture). Hence the corresponding product $ab$ was excluded in (1).
• $5\le s\le 23$, and $s=a+2$ for a prime $a$: The product of $2$ and $a$ was excluded in (1).

Summarizing we see that $s$ must be a number from the following short list:

The remaining candidates for the sum $s$ are 11, 17, 23

For convenience, we now enumerate for every remaining sum-candidate the corresponding products that have not been excluded under (1):

• $s=11$: only 18, 24, 28, 30 are possible products.
• $s=17$: only 30, 42, 52, 60, 66, 70, 72 are possible products.
• $s=23$: only 42, 60, 76, 90, 102, 112, 120, 126, 130, 132 are possible products.

(3) Then Danielle said, "Well, I still don't know what the dimensions are!" Although Danielle knows the product and has deduced the remaining sum-candidates, she is not able to determine the sum. This means that her product $p$ occurrs in the lines of two different sum-candidates. We update the above listing to these doubly occurring product-candidates:

• $s=11$: only 30 is a possible product.
• $s=17$: only 30, 42, 60 are possible products.
• $s=23$: only 42, 60 are possible products.

(4) So Tammy said, "Well, I know what the dimensions are now!" Tammy knows the sum $s$ and the above listing of remaining compatible product-candidates. If the sum was $17$ or $23$, then Tammy would have been left with at least two candidates and would not have known which one was the right one.

Hence, Tammy must have the sum $s=11$.

(5) And Danielle concluded the conversation by saying, "Then I know what the dimensions are too!" Danielle has thought through each of the above steps and has come to the following conclusion:

The sum is $s=11$ and the product is $p=30$.
The dimensions of the farm are 5 and 6 miles, respectively.

• Well played ;-) Feb 12, 2015 at 10:23