Maximizing the product of two numbers in a set given their differences

703 Views Asked by At

This is an interview problem from Glassdoor that I've been unable to solve.

You have all the clubs from a deck, 13 cards, and you can choose 2 from the deck and get paid their product, where all face cards are considered to be 0. You can pay $1 to reveal the difference of any two cards you choose, how much would you pay to play this game?

The answer given is "$79, because the 9 and 10 cards can be found in 11 steps", with no further explanation. Is this answer correct, and if so, how does one arrive at it? I tried diagramming out possible combinations of questions, but that method seems intractable.

1

There are 1 best solutions below

8
On BEST ANSWER

Note: as suggested by the comment below from @user284873 there is an ambiguity in the problem. In my solution below I assumed that we are told the signed difference between the two cards. That is, if I point to $a$ and $b$ I am told $a-b$, as opposed to the absolute difference $|a-b|$. I have not considered the analogous problem where you are told the absolute difference...that might be an interesting variation.

It's clear that you can guarantee getting the $9,10$ if you pay $\$11$. To see that:

Pick a card and start to collect the differences.

Case I: you started with a $0$. In that case there are two $0's$ left out of $12$. You are sure to hit at least one of those in the first $11$ tries. Once you know you have a $0$ you can read off all the other cards from their differences. Seeing $11$ choices certainly determines the final, untested, choice.

Case II: you start with something other than $0$. In that case, there are three $0's$ left so in $11$ tries you are sure to get at least two. Once you see the same difference twice, that will tell you the value of the card you started with and again the $11$ known values will determine the final one.

Note: all this shows is that if you pay $\$11$ then you can guarantee the $\$90$ win. You might be able to do it more cheaply, if you are lucky. For instance, if your first two differences are $10,1$ then you know you started with the $10$ and that the second test card is the $9$. Thus you should be willing to pay more than $\$79$ though computing the exact amount seems like a tedious computation.