Teaser 2490: [Cans of paint]
From The Sunday Times, 13th June 2010 [link] [link]
George and Martha supply paint to the art class. They have 1 litre cans of red, yellow and blue, and can make 2 litre cans of orange (red and yellow equally), purple (red and blue) and green (yellow and blue), and 3 litre cans of brown (red, yellow and blue).
The class orders numbers of litres of all seven colours (totalling less than 500 litres), with the seven numbers forming an arithmetic progression. The lowest quantity is 1 litre; the highest can be shared equally among the class, each student getting a whole plural number of litres. George and Martha used equal quantities of blue and yellow making up the order.
How much green paint was ordered?
This puzzle was originally published with no title.
[teaser2490]
Jim Randell 8:14 am on 14 October 2025 Permalink |
This Python program runs in 69ms. (Internal runtime is 363µs).
from enigma import (irange, inf, first, is_composite, disjoint_cproduct, printf) # colours are: # N = browN, O = Orange, P = Purple, G = Green, R = Red, Y = Yellow, B = Blue # consider common difference in the arithmetic progression for d in irange(1, inf): # calculate the arithmetic progression of quantities qs = first(irange(1, inf, step=d), count=7) t = sum(qs) if not (t < 500): break # final term in the progression is composite if not is_composite(qs[-1]): continue # find terms divisible by 2 (for O, P, G), 3 (for N) (qs2, qs3) = (list(q for q in qs if q % k == 0) for k in [2, 3]) if len(qs2) < 3 or len(qs3) < 1: continue # choose quantities for N (qs3); O, P, G (qs2); R, Y, B (qs) for (N, O, P, G, R, Y, B) in disjoint_cproduct([qs3, qs2, qs2, qs2, qs, qs, qs]): # calculate total volume of R, Y, B used in mixing the colours (O2, P2, G2, N3) = (O // 2, P // 2, G // 2, N // 3) (tR, tY, tB) = (R + O2 + P2 + N3, Y + O2 + G2 + N3, B + P2 + G2 + N3) if tB == tY: # output solution printf("tR={tR} tY={tY} tB={tB} [R={R} Y={Y} B={B} O={O} P={P} G={G} N={N}]")Solution: 58 litres of green paint was ordered (29 cans).
The total amount of paint in the order was 406 litres, consisting of:
Which is mixed as follows:
or:
Giving the following arithmetic progression (with a common difference of 19):
And this is the only possible progression, as it must end with a composite number, have (at least) 3 even numbers and (at least) one number that is divisible by 3.
The largest amount can be expressed as 115 = 5 × 23.
So there are either 5 students in the class (each would receive 23 litres) or 23 students in the class (each would receive 5 litres) (which is probably more likely).
LikeLike
Frits 10:09 am on 14 October 2025 Permalink |
My original program had variable, ABC, DEF, GHI, …
Apparently the number of liters of red paint (r * YZ + 1) is not relevant for solving this teaser.
I didn’t have to use variable “r”.
from enigma import SubstitutedExpression # invalid digit / symbol assignments d2i = dict() for dgt in range(0, 10): vs = set() if dgt > 2: vs.update('Y') if dgt > 6: vs.update('bgnopy') d2i[dgt] = vs # the alphametic puzzle # red: ABC, yellow: DEF, blue: GHI, orange: JKL, purple: MNO # green: PQR, brown: STU p = SubstitutedExpression( [ # difference in arithmetic expression YZ, tot = 21 * YZ + 7 < 500 "YZ < 24", # the highest can be shared equally among the class "not is_prime(6 * {YZ} + 1)", # orange, purple and green "({o} * {YZ} + 1) % 2 == 0", "({p} * {YZ} + 1) % 2 == 0", "({g} * {YZ} + 1) % 2 == 0", # and brow(n) "({n} * {YZ} + 1) % 3 == 0", # equal quantities of blue and yellow making up the order #before "2 * {DEF} + {MNO} == 2 * {GHI} + {JKL}", "2 * {y} + {p} == 2 * {b} + {o}", ], answer="g * YZ + 1", symbols="YZbgnopy", d2i=d2i, distinct=("bgnopy"), verbose=0, # use 256 to see the generated code ) # print answers print("answer:", ' or '.join(set(str(x) for x in p.answers())), "liters")LikeLike