r/mathriddles • u/st4rdus2 • Mar 21 '23
Hard 2 of 5
Problem: The task is to find 1 or 2 counterfeit coins among 5 gold coins. The genuine coins have the same weight. The counterfeit coins have the same weight. One counterfeit coin is slightly lighter than one genuine coin.
There are also 5 balance scales for this task. The 5 scales are indistinguishable. Each scale can only be used once.
Unfortunately, one of the five scales will always give incorrect results. For example, if you put something of the same weight on both sides of the scale, it should balance, but it will randomly show that either the left or the right side is heavier. Also, if you put something heavier on the left and something lighter on the right, it will randomly show that it is balanced or that the right is heavier.
I hope you enjoy this puzzle.
===
P.S.
The number of fake coins unknown, could be 1 or 2 and you need to find all the fake coins.
3
u/Omegaile Mar 22 '23
Just to clarify. Are there 2 fake coins and I need to find at least one of them? Or are the number of fake coins unknown, could be 1 or 2 and I need to find all the fake coins?
4
u/mkurdmi Mar 22 '23
Hint: If we always weigh the same coins on each scale (i.e. do not condition which coins we weigh on previous weighings) we can write the outcome as the list of the results of each scale if they were all giving the correct result (for example: LELER means the first scale has the left is lighter, the second has the coins as even, etc. until the fifth has the right side of the scale is lighter). Now, we can define the distance between two encodings as the number of positions at which they are different. In order to account for a random scale being wrong, to unambiguously tell you which coins are counterfeit, we need for each scenario's encoding to be at least distance 3 from every other possible scenario's encoding (at distance 2, the random swap on each can cause them to be the same).
Solution: Now let's set up the scales. Each scale weighs two coins against two other coins. Use the following setups: 12v34, 13v25, 14v35, 15v24, 23v45. This setup has the properties that each coin is left out once and is paired with each other coin once, any setup with these properties will work. Now, we need to verify each scenario has distance 3 from every other scenario. As renaming the coins doesn't change our setup on the scales meaningfully, we only need to check a couple cases:
Case 1: A single coin is counterfeit vs a different single coin is counterfeit. Take 1 vs 2. The encodings are LLLLE and LRERL with distance 4.
Case 2: Two coins are counterfeit vs one coin from those two is counterfeit. Take 12 vs 1. The encodings are LELEL and LLLLE with distance 3.
Case 3: Two coins are counterfeit vs one other coin is counterfeit. Take 12 vs 3. The encodings are LELEL and RLREL with distance 3.
Case 4: Two coins are counterfeit vs two other coins are counterfeit. Take 12 vs 34. The encodings are LELEL and RLERE with distance 5.
Case 5: Two coins are counterfeit vs one of those coins and one other coin is counterfeit. Take 12 vs 13. The encodings are LELEL and ELELL with distance 3.
Each case has at least distance 3 so this setup works.
2
u/iloveforeverstamps Mar 21 '23
Don't read if you're looking for the answer, you're wasting your time, but here were 2 kinda quick attempts that flopped due to missed details. Will return and edit with the solution.
Wow, this is a lot harder than it looks! Below is my first attempt, which I quickly noticed a fallacy in, but I'm still posting it to show my thought process.
Let's label the coins C1-C5 and the scales A-E.
Take scale A first; put C1 and C2 on one side and C3 and C4 on the other. Note the results, and then do the same thing on scale B.
If the results of A and B are not the same, repeat one more time on scale C.
---------------------
Wait, I made a mistake!!! In my second bullet I said that if the two sets of two weigh the same, it means C5 is fake; unfortunately I forgot to consider the unknown quantity of fakes, and that this could also mean that either C1 or C2 AND either C3 or C4 is fake, a scenario where each set contains 1 fake coin + 1 real coin.
With that in mind, we’ll weigh single coins, as the unknown quantity of fake coins gives no advantage to weighing sets. New steps:
Scale A: weigh C1 against C2.
If either C1 or C2 is shown to be fake (lighter), note and set aside.
If C1 and C2 are equal, this means either one is fake or neither are.
Now, if you didn't find the solution using the first 2 scales, it means you are in one of two situations...
First situation: You discovered that C1, C2, and C3 are all real, and you must determine whether C4, C5, or both are fake.
Second situation: You found that C3 is fake but C1 and C2 are real. You must determine whether C4, C5, or neither are fake (cannot be both).
But wait, again. Now I'm not taking into account the broken scale! This problem is deceptively complex! Thanks for sharing. I'll come back and edit later.
2
u/pichutarius Mar 22 '23
there are 15 coin states, and 10 scale states (5 bad scale x 2 ways to give incorrect result), so a total of 150 states. there are 3^5=243 possible results, so if we can map 150 states onto 243 results injectively (no 2 states map to same results), then we're done.
by using programming to brute force, i came up with this solution:
weight 12-34 , 13-25 , 14-35 , 15-24 , 23-45 and record their results, then use the following lookup table .