## Interview Question

## Interview Answer

13 Answers

A better answer:

Split the 8 pennies into 3 groups of 3,3,2 pennies. Weight the first two groups of 3 pennies each.

Case 1) - They weight the same. Therefore, take third group of 2 pennies and find the lighter coin.

Case 2) Group 1 weights more than Group 2. Take group 2 (3 pennies) and pick any 2 out of 3. If they weight the same, then the third penny is lighter. Answer is trivial if they don't weight the same.

It works for any scenario. Always split the groups in 3.

It's a lot simpler than you'd think

Divide the current number of coins by two and put them on both sides of the scale, remove the side that weighs more, and divide the lighter side in half, repeat

so you start with 8:

|||| |||| (4/4)

|| || (2/2)

| | (1/1)

Three steps, simple, logical, and and can get the right answer each time.

Neil has it right. Dave - the question says less than three steps.

Actually, Neil is still correct. The question does not say less than three steps, it says three steps. You must have misread it Tim. "Find the penny that weighs less in three steps." not less than, it's less in... And they both seem as though they would work and be relatively simple to perform, explain, and understand.

I Can do it in one step: Look at the year on the pennies.

If 7 pennies weigh the same it means that all 7 were manufactured either before or after 1982, when the mint changed the composition of the coin from solid copper to copper with a zinc core. the one that weighs differently was minted on the opposite side of 1982 as the 7 other pennies.

To clarify and adhere to the the question better. the 7 pennies that weigh the same are pre 1982 and the one that weights less is post 1982 because zinc weighs less than copper.

but like I said. the one step is to simply look at the date.

Step One:

Place two pennies aside and weigh 3 vs 3.

Step Two:

If they are equal then weigh the two other pennies.

If a group of three pennies contains the lighter penny then cut one of them in half. Weigh the two groups of one and a half pennies. If its equal then the cut penny is the lightest, otherwise it is the whole penny on the lighter side.

Neil's method works in 2 steps.

On reflection, I think Bharat has the same method but did not explain it very well so it is hard to know.

Uh...I read the question like this. "Find the one that weighs less IN LESS THAN 3 steps." It's pretty clear to me what it says.

Matthew, that answer is AWESOME!!! Assuming of course they didn't add any crud like dirt, gum, etc. to the pre-1982 penny and 6 others to weigh equally, while the one remaining is newly minted. I'll remember that one.

Dave, your answer is great. The feedback you got is a great lesson for us because you clearly answered the question and others need to ensure in an interview that they answer what is asked, pay attention and ask for clarification. You win Dave- great job!

Great answer and explanation here:

http://www.programmerinterview.com/index.php/puzzles/25-horses-3-fastest-5-races-puzzle/

Oops sorry, the answer is here:

http://www.programmerinterview.com/index.php/puzzles/8-pennies-find-lightest-7-equal/

## Add Answers or Comments

To comment on this, Sign In or Sign Up.

Set two pennies aside, put 3 on each scale and if they weight the same the lighter one is one of the other two, if not it is one of the three on the scale, repeat for the two or three remaining.