8
$\begingroup$

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.

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

2 Answers 2

10
$\begingroup$

0 from one bag, 1 from another, 3 from the other gives:
$0\cdot0+1\cdot1+3\cdot2=7$
$0\cdot0+3\cdot1+1\cdot2=5$
$1\cdot0+0\cdot1+3\cdot2=6$
$1\cdot0+3\cdot1+0\cdot2=3$
$3\cdot0+0\cdot1+1\cdot2=2$
$3\cdot0+1\cdot1+0\cdot2=1$
as the remainder $\pmod{10}$, which are all distinct, and $4$ coins weigh less than 50grams.

$\endgroup$
4
$\begingroup$

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,
    list_allperms([X,Y,Z],L),
    maplist(fit_limit, L),
    maplist(fit_unique,L,R),
    all_distinct(R),
    label([X,Y,Z]),
    write(R).

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.

$\endgroup$

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.