I've posted a solution to counting coins here:
http://tech.bluesmoon.info/2010/11/counterfeit-coins-solutio...
Let me know if you think it's right or wrong.
Let me know if you think it's right or wrong.
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.