There are many coin weighing puzzles. So a general attribution to all of them. (And I will fully understand if you completely ignore this one). Hope this is not a duplicate.

But I think this is a little different :)

There are 3 bags of coins. Ten coins in each bag. They look exactly the same.

One bag, let's say has normal weight coins. All 10 grams each.

Second bag has coins that weigh exactly 11 grams each.

And the third bag has coins that weigh exactly 12 grams each.

Of course you do not know which bag is which.

There is a digital "pan" type scale on which you have to press a button to get the weight reading. Importantly, the scale cannot read over 50 grams

You are allowed only one weight reading. Only from that reading you must decide which bag has 10 gram coins, which bag has 11 gram coins and which one has 12 gram coins. No other ways are allowed.

  • $\begingroup$ Apparently this scale does not also have a TARE button, which is too bad -- it opens up some alternate approaches. $\endgroup$
    – Roger
    Dec 2, 2019 at 20:49

2 Answers 2


0 from one bag, 1 from another, 3 from the other gives:
as the remainder $\pmod{10}$, which are all distinct, and $4$ coins weigh less than 50grams.


With the following code let prolog search the results - X, Y, Z are the coefficients for each bag.

:- use_module(library(clpfd)).

list_allperms(L, Ps) :- bagof(P, permutation(L,P), Ps).

f(X,Y,Z,R) :- R #= 10 * X + 11 * Y + 12 * Z.
fit(X,Y,Z) :- f(X,Y,Z,R), R #< 51.

fit_limit(L) :- nth0(0,L,X),nth0(1,L,Y),nth0(2,L,Z),fit(X,Y,Z).
fit_unique(L,R) :- nth0(0,L,X),nth0(1,L,Y),nth0(2,L,Z),f(X,Y,Z,R).

solution(X,Y,Z) :-
    X #>=0,
    Y #>=0,
    Z #>=0,
    maplist(fit_limit, L),

The output comes out to be

R1 = 47, R2 = 46, R3 = 45, R4 = 42, R5 = 41, R6 = 43, X = 0, Y = 1, Z = 3 {0,1,3} is a symmetric solution for {X,Y,Z}

Ri's are the unique combination weights for each permutation of bags and coefficients.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.