Teaser 3099: Recurring theme
From The Sunday Times, 13th February 2022 [link] [link]
Liam is learning about fractions and decimals. He has been shown that some fractions give rise to decimals with a recurring pattern eg 4/11 = 0.3636… . Each pupil in his class has been given four numbers. The largest (two-figure) number is to be used as the denominator and the others as numerators, to create three fractions that are to be expressed as decimals. Liam found that each decimal was of the form 0.abcabc…, with the same digits but in different orders.
Liam’s largest number contained the digit 7 and if I told you how many of his four numbers were divisible by ten you should be able to work out the numbers.
What, in increasing order, are the four numbers?
[teaser3099]
Jim Randell 3:42 pm on 11 February 2022 Permalink |
We can use some handy routines from the enigma.py library to help in solving this puzzle. [[
recurring()]] finds the recurring part of the decimal representation of a fraction, and [[filter_unique()]] can be used to find sets that are unique by the count of multiples of 10 involved.The following Python program runs in 91ms.
Run: [ @replit ]
from enigma import (defaultdict, irange, union, recurring, join, subsets, filter_unique, printf) # generate sets of possible numbers def generate(): # choose the denominator (2-digits, one of them a 7) for d in union([irange(17, 97, step=10), irange(70, 79)]): # consider the smaller numbers, n/d = 0.(xyz)... # and record them by the digits that make up the repetend r = defaultdict(list) for n in irange(1, d - 1): (_, nr, rr) = recurring(n, d) if (not nr) and len(rr) == 3: r[join(sorted(rr))].append(n) # find sets of 3 numerators for ns in r.values(): for ss in subsets(ns, size=3, fn=list): yield tuple(ss + [d]) # find sets unique by the count of multiples of 10 involved fn = lambda ns: sum(n % 10 == 0 for n in ns) for ns in filter_unique(generate(), fn).unique: printf("{ns}")Solution: Liam’s numbers are: 4, 30, 40, 74.
So we have:
And this the only set of 4 numbers where 2 of them are divisible by 10.
In all there are 30 possible sets of 4 numbers. 12 sets use a denominator of 37, and the numbers in these sets can be multiplied by 2 to give 12 further sets (that give the same fractions) using a denominator of 74. The remaining 6 sets have a denominator of 27.
Of these there are 19 sets with none of the 4 numbers divisible by 10, and 10 sets with one of the 4 numbers divisible by 10. The remaining set has two of the numbers divisible by 10, and so gives the answer.
LikeLike
GeoffR 3:09 pm on 15 February 2022 Permalink |
Not very elegant code, but it finds the answer, and runs in less than 100ms.
I used two Python dictionaries in this solution.
from enigma import recurring, join from collections import defaultdict # for potential number lists Nums = defaultdict(list) # for counting values in Nums divisible by 10 D10 = defaultdict(list) # using list of possible denominators including digit 7 # .. to search for repeating decimal patterns for n in (17,27,37,47,57,67,70,71,72,73,74,75,76,77,78,79,87,97): (_, nr, rr) = recurring(1, n) if not(nr) and len(rr) == 3: print(f"Number = {n}, reciprocal = {1/n}") # only 27 and 37 were found as denominators with repeating patterns # ... add multiples 54 and 74 as extra 2-digit numbers # ...in search for all 3-digit repeating patterns for n in range(1, 80): for d in (27, 37, 54, 74): if n < d: (_, nr, rr) = recurring(n, d) if not(nr) and len(rr) == 3: Nums[join(sorted(rr)) + " " + str(d)].append(n) # add denominator (from the key) to values for k, v in Nums.items(): v = v + [int(k[4:6])] # form a new dictionary D10, based on the Nums dict values # ... which are divisible by 10 for k, v in Nums.items(): tot10 = 0 # count numbers divisible by 10 for x in v: q, r = divmod(int(x), 10) if q and r == 0: tot10 += 1 # add denominator to D10 values D10[tot10].append(v + [int(k[4:6])] ) # look for a unique set of four numbers # ... based on the number of values divisible by 10 for k, v in D10.items(): if len(v) == 1: print(f"Four numbers are {v}")LikeLike
A.T.Surherland 9:40 am on 16 February 2022 Permalink |
I have obtained an interesting answer :-
The sum of the 3 lowest numbers = the greatest number.
ie the sum of the fractions = 1.
Is there a reason for this condition?.
LikeLike
Jim Randell 12:01 pm on 16 February 2022 Permalink |
There are 12 sets of numbers that work with a denominator of 37. Of these 6 have the fractions sum to 1, and 6 have the fractions sum to 2. And we can obviously multiply all the numbers up by a factor of 2 to get another 12 sets that behave the same.
The remaining 6 sets of numbers (with denominator 27) give fractions that don’t sum to a whole number (but are all multiples of 1/9).
This is presumably due to the 3 different digits in the repetends lining up, so that the repetend of the sum is a single digit, and in the case of .(9)… this gives a whole number.
LikeLike
Brian Gladman 12:29 pm on 16 February 2022 Permalink |
If we add 0.abc… + 0.bca… + 0.cab… we will get 0.111… x (a + b + c) = (a + b + c) / 9, so sum(numerators) / denominator = (a + b + c) / 9. So this happens when a + b + c == 9, which it does in our case. The sum can be 2 when a + b + c equals 18 but it is not necessarily an integer.
LikeLike
GeoffR 11:07 am on 16 February 2022 Permalink |
Yes, This is my understanding of the reason.
A repeating fraction of the format 0.abcabcabc.. can be expressed exactly as a rational fraction abc/999 – see number theory elsewhere.
Each of the three numerators in the answer divided by the denominator, gives a 3-digit repeating pattern.
Without displaying the answer publicly, as this is a current Sunday Times Teaser,
the three repeating fractions for this teaser can be expressed as:
0.abcabcabc 0.cabcabcab 0.bcabcabca – since the three fractions use the same digits as a stated teaser condition.
The rational fractions for this teaser are then abc/999, cab/999 and bca/999.
Also, abc + cab + bca = 999.
It can be seen that abc/999 + cab/999 + bca/999 = 1.
LikeLike