Skip to content

Instantly share code, notes, and snippets.

@shintakezou
Last active April 9, 2016 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shintakezou/b7408703f1d8ab5bcf544500dc8a7038 to your computer and use it in GitHub Desktop.
Save shintakezou/b7408703f1d8ab5bcf544500dc8a7038 to your computer and use it in GitHub Desktop.
Find the solution of "Un quesito con la Susi 932" in METAFONT
%
% Problem from the Italian weekly magazine "La Settimana Enigmistica"
%
%
% Three couples divided their earnings (1000euro) from their
% second-hand clothes shop.
%
% The sum of the shares of the wives is 396.
%
% Giovanna (g) had 10e more than Carla (c);
%
% Marta (m) had 10e more than Giovanna (g);
%
% We also know that Dario (d) had the same amount as his wife; Tommaso
% (t) had double the amount of his wive; Enrico (e) had 1.5 times the
% amount of this wife.
%
% The problem asks you to tell who's Dario's wife.
%
% The following is a rough "solution" in METAFONT. In fact the
% solution must be deduced from the output (the number links
% Dario to his wife pretty easily).
%
% c, g, m, d, t, e, all are numbers
numeric c, g, m, d, t, e;
% the problem states that:
c + g + m = 396;
g = 10 + c;
m = 10 + g;
% we've the first result already
message "Carla=" & decimal(c) & char(10) &
"Giovanna=" & decimal(g) & char(10) &
"Marta=" & decimal(m);
% let's test all the possible couples and see
% which arrangement satisfies the relationship (*)
for va = c, g, m:
for vb = c, g, m:
for vc = c, g, m:
if (va <> vb) and (va <> vc) and (vb <> vc):
d := va; % Dario had the same share as his wife
t := 2vb; % Tommaso had twice the share of his wife
e := 1.5vc; % Enrico had 1.5 times the share of his wife
if va + vb + vc + d + t + e = 1000: % (*)
message "Dario=" & decimal(d);
fi
fi
endfor
endfor
endfor
bye;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment