Brain-Teaser 25: [Exam results]
From The Sunday Times, 10th September 1961 [link]
“These examination results show that either the knowledge of mathematics, physics, and chemistry throughout the school is deplorable weak, or the papers were very stiff”, said the headmaster to the staff concerned.
“Unfortunately, I have mislaid the detailed list, but some of the figures are easy to remember. The number of pupils taking the three subjects was 440. In chemistry 200 passed; in physics 210 failed; and in mathematics 220 passed. Of those who passed in chemistry 66 failed in mathematics, whereas of those who passed in mathematics 22 failed in physics. I cannot recall the number of pupils who passed in all three subjects, or the number who failed in all three, but both these numbers were perfect squares”. At this stage the senior mathematics master got out his pencil and paper and started to puzzle it out.
(1) How many pupils failed in all three subjects?
(2) Of those who passed in chemistry, how many also passed in physics?
This puzzle was originally published with no title.
[teaser25]
Jim Randell 9:40 am on 7 March 2021 Permalink |
For each of the three subjects a student can either pass or fail. So there are 8 regions in the corresponding Venn diagram.
And if we had been given the square numbers for those that passed in all three subject and failed in all three subjects we would have 8 equations in 8 variables, so we would be able to work out the values for each of the variables.
And the missing squares must be less than 15².
The following Python program runs in 79ms.
from enigma import (matrix, as_int, subsets, powers, printf) # solve the equations given values for MPC and X def solve(MPC, X): # set up the equations eqs = [ # X M P C MP MC PC MPC = k ((1, 1, 1, 1, 1, 1, 1, 1), 440), ((0, 0, 0, 1, 0, 1, 1, 1), 200), ((1, 1, 0, 1, 0, 1, 0, 0), 210), ((0, 1, 0, 0, 1, 1, 0, 1), 220), ((0, 0, 0, 1, 0, 0, 1, 0), 66), ((0, 1, 0, 0, 0, 1, 0, 0), 22), ((0, 0, 0, 0, 0, 0, 0, 1), MPC), ((1, 0, 0, 0, 0, 0, 0, 0), X), ] # solve for non-negative integers try: (X, M, P, C, MP, MC, PC, MPC) = (as_int(x, "0+") for x in matrix.linear(eqs)) except ValueError: return printf("X={X} M={M} P={P} C={C} MP={MP} MC={MC} PC={PC} MPC={MPC}") # consider possible squares for X and MPC for (MPC, X) in subsets(powers(0, 14, 2), size=2, select="M"): solve(MPC, X)Solution: (1) 144 pupils failed all three subjects; (2) 143 passed in chemistry and also physics.
We can make a table of the regions of the Venn diagram
LikeLike
Frits 12:25 pm on 8 March 2021 Permalink |
Based on Jim’s solution, with some analysis so no “==” operators are used (to avoid loops).
@Jim, the generated code is not efficient as possible as there is a loop for O and Q when CF is already known.
from enigma import SubstitutedExpression, is_square # the alphametic puzzle p = SubstitutedExpression( [ # X M P C MP MC PC MPC #XYZ + MA + PDE + CF + HI + KL + OQ + STU = 440 #"352 - XYZ - HI - STU = PDE", # substitute MA + KL = 22 and CF + OQ = 66 "352 - XYZ - HI - STU >= 0", # CF + KL + OQ + STU = 200 "112 + MA = STU", # substitute CF + KL = 88 - MA - OQ #XYZ + MA + CF + KL = 210 "188 - CF = XYZ", # MA + HI + KL + STU = 220 "198 - STU = HI", # substitute KL = 22 - MA # CF + OQ = 66 "66 - OQ = CF", # MA + KL = 22 "22 - MA = KL", "is_square(STU)", "is_square(XYZ)", ], answer="STU, HI, KL, MA, OQ, 352 - XYZ - HI - STU, CF, XYZ", d2i=dict([(0, "SX")] + [(k, "M") for k in range(3, 7)] + [(k, "MCO") for k in range(7, 10)]), distinct="", verbose=0 ) for (_, ans) in p.solve(): print("pupils failed in all three subjects =", ans[0]) print("Of those who passed in chemistry", ans[0] + ans[4], "also passed in physics")LikeLike
Frits 12:57 pm on 8 March 2021 Permalink |
It can easily be seen that MA has to be 9 (square 121) and CF has to be 19 or 44 (squares 169 and 144).
LikeLike
John Crabtree 5:15 pm on 10 March 2021 Permalink |
C = 66 – CP and M = 22 – CM.
From chemistry, CM + CMP = 200 – 66 = 134, with CM <= 22
And so CMP = 121 and CM = 13.
From maths, MP = 200 – 22 – CMP = 77
From physics, P = 230 – MP – CP – CMP = 32 – CP, and so CP <= 32
From all eight variables, 318 – CP + X = 440, ie X = 122 + CP
And so X = 144 and CP = 22
The answers follow directly.
LikeLike