Last active
April 9, 2016 21:34
-
-
Save shintakezou/b7408703f1d8ab5bcf544500dc8a7038 to your computer and use it in GitHub Desktop.
Find the solution of "Un quesito con la Susi 932" in METAFONT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% 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