Sunday Times Teaser 2490 – No Title
by Danny Roth
Published June 13 2010 (link)
George and Martha supply paint to the art class. They have 1l cans of red, yellow and blue, and can make 2l cans of orange (red and yellow equally), purple (red and blue) and green (yellow and blue), and 3l cans of brown (red, yellow and blue).
The class orders numbers of litres of all seven colours (totalling less than 500l), with the seven numbers forming an arithmetic progression. The lowest quantity is 1l; 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?
One Comment
Leave one →
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829303132333435from itertools import product, permutationsfrom number_theory import is_prime# let the numbers of litres be 1, m + 1, 2.m + 1 ... 6.m + 1# (the total number of litres is < 500 so m is less than 24)for m in range(1, 24):# the highest amount is a multiple of the number of studentsif is_prime(6 * m + 1):continue# the seven paint amountsam7 = range(1, 7 * m + 1, m)# the brown amount is a multiple of threefor brown in (x for x in am7 if x % 3 == 0):# the six remaining amountsam6 = tuple(x for x in am7 if not x == brown)# the green, orange and purple amounts are evenfor p in permutations((x for x in am6 if x % 2 == 0), 3):orange, purple, green = p# the red, yellow and blue amountsfor q in permutations((x for x in am6 if x not in p), 3):red, yellow, blue = q# the litres of red, yellow and blue used in the paintsl_red = red + (orange + purple) // 2 + brown // 3l_yellow = yellow + (orange + green) // 2 + brown // 3l_blue = blue + (purple + green) // 2 + brown // 3if l_yellow == l_blue:print(f'green {green} (red {red}, yellow {yellow:>3}, blue {blue:>3}, 'f'orange {orange}, purple {purple}, brown {brown}) 'f'(totals: red {l_red}, yellow {l_yellow}, blue {l_blue}).')