Hacker News new | ask | show | jobs
by aralib 5690 days ago
Your solution is not correct. For example, if the counterfeit pile is initially measured with one coin and Delta is -1 (29 modulo 30), you set D1 to 1, but D2 will be 28, 29, or 30. You cannot determine Delta or the counterfeit pile with such values of D1 and D2 using your algorithm.

It's certainly not the case that D{1,2} <= 20 as your comments suggest, and you seem to realize this by checking for D1 >= 25. Also, you ignore the case of 20 < D1 < 25.

Note that Delta is strictly between -5 and 5, so it can't be equal to -5 or 5.

There is actually a really elegant solution to this problem. I'll send you an email so you can let me know if you'd like a hint.

1 comments

Thanks, I see the issue.