From The Sunday Times, 3rd May 1992 [link]
This week, I share a find-the-next-row puzzle that is doing the rounds of dons’ whiteboards:
1
1 1
2 1
1 2 1 1
?
To avoid invasion of ivory towers, I will give you the answer:
1 1 1 2 2 1
with the explanation that, starting with the initial 1, each subsequent row is obtained by reading the previous row. Thus, row five is formed (with reference to row four) from one “one”, followed by one “two”, and terminating with two “one”s.
However, I do have four questions about the first billion rows of this sequence.
1. What is the largest digit that can be found anywhere?
2. What is the largest number of ones that can occur consecutively in any single row?
3. Repeat (2), looking for twos instead.
4. Repeat (2), looking for threes instead.
Multiply each answer by its question number and send in the total.
This puzzle is included in the book Brainteasers (2002), in which it appears in the following form:
Read me!
Consider the sequence:
1
11
21
1211
111221
312211
…
You might like to try and work out the next few terms before reading on and trying the rest of this Teaser.
In fact, having started with 1, each subsequent term simply reads the previous line. So, for example, after 111221 we note that this consists of:
three ones, two twos, one one
i.e. the next term is simply:
312211
Here are some questions about the first billion terms of this sequence:
(a) What is the largest number of consecutive ones in any term?
(b) What is the largest number of consecutive twos in any term?
(c) What is the largest number of consecutive threes in any term?
(d) What is the largest digit which can be found in any term?
[teaser1547]
Jim Randell 1:37 pm on 5 May 2019 Permalink |
If the scores in the first five innings are (a, b, c, d, e) and there are scores for the sixth innings f, (between 0 and 29), that continue the pattern. And there will be a smallest such value:
So, we can look at all possible (a, b, c, d, e, f) values and find the largest possible f_min value.
This Python program runs in 569ms.
Run: [ @repl.it ]
from enigma import (irange, Accumulator, printf) # possible next scores def scores(ss, avgs): t = sum(ss) n = len(ss) + 1 for s in irange(-t % n, 29, step=n): if s not in ss: yield (ss + [s], avgs + [(t + s) // n]) # find sequences of length k def solve(ss=[], avgs=[], k=5): if len(ss) == k: yield (ss, avgs) else: for (ss1, avgs1) in scores(ss, avgs): yield from solve(ss1, avgs1, k) # find the largest of the smallest values r = Accumulator(fn=max) for (ss, avgs) in solve(): # find the smallest score to maintain this for (ss1, avgs1) in scores(ss, avgs): s = ss1[-1] r.accumulate(s) if s == r.value: printf("scores={ss} (avgs={avgs}) -> score={s} (avg={avg})", avg=avgs1[-1]) break # we only want the smallest value # output the solution printf("max value = {r.value}")Solution: The largest number it could have been is 23.
I found 142 sequences that give this largest possible f_min value, although only 15 of these also have the averages take on 5 different values.
One possible sequence is:
which give the corresponding averages of:
A score in the sixth innings of 23, would give an average of 18 over the six innings.
LikeLike