Brain-Teaser 776: Christmas shopping
From The Sunday Times, 30th May 1976 [link]
My three nieces Anne, Betty and Carole came to stay with me just before Christmas. When they arrived they handed over their “present” money, and as I wrote down the amounts (in pence) I noticed that they were 3-digit numbers using all nine digits (zero excluded) and that Anne had more than Betty and Carole had as much as the other two together.
I drove the girls into town to shop and as they entered the car to return home they again asked me to look after their money. As I jotted down the three amounts I noticed that they were 3-digit numbers using all nine digits as before.
Before I drove off they wanted to know how much each had spent. As I told them these amounts I was struck by the fact that they were 3-digit numbers again using all nine digits. I also added that Carole had spent exactly three-fifths of her money while Anne had spent a little more than three-fifths of hers.
How much did the three girls have for the rest of their stay?
This puzzle was included in the book The Sunday Times Book of Brain-Teasers: Book 1 (1980, edited by Victor Bryant and Ronald Postill). The puzzle text above is taken from the book.
[teaser776]




Jim Randell 7:19 am on 15 June 2021 Permalink |
We can use the [[
SubstitutedExpression]] solver from the enigma.py library to solve this puzzle.The following run file executes in 85ms.
Run: [ @replit ]
#! python3 -m enigma -rr SubstitutedExpression --digits="1-9" --distinct="ABCDEFGHI,JKLMNPQRS,TUVWXYZab" # initial amounts: Anne = ABC; Betty = DEF; Carole = GHI "{A} > {D}" # ABC > DEF "{GHI} - {ABC} = {DEF}" # GHI = ABC + DEF # final amounts: Anne = JKL; Betty = MNP; Carole = QRS # amounts spent: Anne = TUV; Betty = WXY; Carole = Zab "{ABC} - {TUV} = {JKL}" "{DEF} - {WXY} = {MNP}" "{GHI} - {Zab} = {QRS}" # Carole had spent 3/5 of her money "div(3 * {GHI}, 5) = {Zab}" # Anne had spent a little more than 3/5 of hers (say: > 60%, < 65%) "0.60 < fdiv({TUV}, {ABC}) < 0.65" # the answer is the final amounts --answer="({JKL}, {MNP}, {QRS})"Solution: The remaining amounts are: Anne = 245p; Betty = 169p; Carole = 378p.
The initial amounts are:
And the amounts spent are:
LikeLike
GeoffR 10:27 am on 15 June 2021 Permalink |
% A Solution in MiniZinc include "globals.mzn"; % using same notations as Jim's solution % starting amounts - Anne, Betty and Carole var 1..9:A; var 1..9:B; var 1..9:C; var 1..9:D; var 1..9:E; var 1..9:F; var 1..9:G; var 1..9:H; var 1..9:I; var 100..999:ABC = 100*A + 10*B + C; % Anne var 100..999:DEF = 100*D + 10*E + F; % Betty var 100..999:GHI = 100*G + 10*H + I; % Carole var set of int: start = {A,B,C,D,E,F,G,H,I}; constraint start == {1,2,3,4,5,6,7,8,9}; % Anne had more than Betty and % Carole had as much as the other two together. constraint ABC > DEF /\ GHI == ABC + DEF; % final amounts - Anne, Betty and Carole var 1..9:J; var 1..9:K; var 1..9:L; var 1..9:M; var 1..9:N; var 1..9:P; var 1..9:Q; var 1..9:R; var 1..9:S; var 100..999:JKL = 100*J + 10*K + L; % Anne var 100..999:MNP = 100*M + 10*N + P; % Betty var 100..999:QRS = 100*Q + 10*R + S; % Carole var set of int: final = {J,K,L,M,N,P,Q,R,S}; constraint final == {1,2,3,4,5,6,7,8,9}; % amounts spent - Anne, Betty and Carole var 1..9:T; var 1..9:U; var 1..9:V; var 1..9:W; var 1..9:X; var 1..9:Y; var 1..9:Z; var 1..9:a; var 1..9:b; var 100..999:TUV = 100*T + 10*U + V; % Anne var 100..999:WXY = 100*W + 10*X + Y; % Betty var 100..999:Zab = 100*Z + 10*a + b; % Carole var set of int: spent ={T,U,V,W,X,Y,Z,a,b}; constraint spent == {1,2,3,4,5,6,7,8,9}; % for Anne, Betty and Carole, amount_left = starting_amount - amount_spent constraint ABC - TUV == JKL /\ DEF - WXY == MNP /\ GHI - Zab == QRS; % Carole had spent 3/5 of her money constraint 3 * GHI == 5 * Zab; % Anne had spent a little more than 3/5 of her money (say less than 4/5) constraint 5 * TUV > 3 * ABC /\ 5 * TUV < 4 * ABC; solve satisfy; output ["Starting amounts(p) for Anne, Betty & Carole: " ++ show(ABC) ++ ", " ++ show (DEF) ++ ", " ++ show(GHI) ++ "\nFinal amounts(p) for Anne, Betty & Carole: " ++ show(JKL) ++ ", " ++ show(MNP) ++ ", " ++ show(QRS) ++ "\nAmounts spent(p) for Anne, Betty & Carole: " ++ show(TUV) ++ ", " ++ show(WXY) ++ ", " ++ show(Zab)]; % Starting amounts(p) for Anne, Betty & Carole: 627, 318, 945 % Final amounts(p) for Anne, Betty & Carole: 245, 169, 378 % Amounts spent(p) for Anne, Betty & Carole: 382, 149, 567 % time elapsed: 0.38 s % ---------- % ==========LikeLike