2008年1月22日星期二

Microsoft Interview Question 4

Question:
How do you cut a rectangular cake into two equal pieces with one straight cut when someone has already removed a rectangular piece from it? (The removed piece can be of any size or any orientation.)


Answer:
This question definitely has a right answer. It might be argued that it involves a bit of a "trick", but I still like it. The trick is knowing or realizing that any line passing through the center point of a rectangle bisects it. Before you remove the rectangular piece from the cake, there are infinitely many lines which bisect the cake. After you remove the rectangular piece, there is only one - the line which passes through both the center of the cake, and the center of the removed rectangular piece. This line necessarily divides the removed piece in half, and hence the same amount of cake was removed from each half of the remaining portion.

The value in this question is not only seeing if a candidate can compute the answer, but watching them eliminate non-solutions. You would probably realize after a little trial-and-error that such a constraint is not helpful, and that might guide them toward the solution.



P.S. There is another solution - cut the cake in half vertically! (With a single horizontal slice.) I'd say this gets points for creativity, but I'd still want to see the candidate solve the problem the other way.


Question:

The $21 Question
Alan and Vicky have $21 between them. Alan has $20 more than Vicky. How much does each have (you can't use fractions in the answer)?


Answer:
I called this the worst question in the book, based on the fact that it has no answer. I went on to say:

Apparently sometimes people ask questions which have no answer to see how candidates react. This might be helpful in some situations (if you're hiring for a company with a confrontational culture!), but I would never use it; I don't like what it says about me and my company, and I can't imagine what it would say about the candidate, either.

However, I found out that this question does have an answer!
What does this illustrate? That many people apparently doesn't know that dollars are divided up into cents:

A = V + 2000¢
A + V = 2100¢

Hence,

A = 2050¢
V = 50¢

Excellent! When I read this question in the book it was described as having no answer, and it never occurred to me that the book was wrong, and that this question really does have an answer. This is a classic "thinking out of the box" test. Any candidate is going to do the algebra and conclude that there is no integer solution in dollars. Will they then consider shifting units to cents? Very interesting.

沒有留言: