## Teaser 2971: Six sisters on the ski lift

**From The Sunday Times, 1st September 2019** [link]

The sum of the ages of six sisters known to me is 92. Though there is no single whole number greater than 1 that simultaneously divides the ages of any three of them, I did notice this morning, while they lined up for the ski lift, that the ages of any two of them standing one behind the other, had a common divisor greater than 1.

In increasing order, how old are the six sisters?

[teaser2971]

## Jim Randell 8:06 am

on30 August 2019 Permalink |This program builds up a list of the ages in the order they appear in the queue, such that each consecutive pair share a common factor (greater than 1), but no 3 of them have a common factor (greater than 1).

It runs in 818ms.

Run:[ @repl.it ]Solution:The ages of the sisters are 7, 10, 13, 15, 21, 26.They are queuing in the order (7, 21, 15, 10, 26, 13), or the reverse of this.

Which we can factorise as: (7, 7×3, 3×5, 5×2, 2×13, 13). So the common factors are 7, 3, 5, 2, 13.

And, in fact, picking a sequence of different prime numbers and then multiplying them together in pairs will give us a sequence where consecutive pairs share a factor, but no three numbers share a common factor.

However this procedure will not necessary find all possible solutions. For example, if the required total had been 102, there is a possible queue of (7, 7×5, 5×3, 3×2×2, 2×11, 11) that cannot be constructed in this way (note the 3×2×2 term), but it is found by the program.

LikeLike

## Jim Randell 2:17 pm

on31 August 2019 Permalink |Here is an alternative approach that uses a bit of analysis.

Each consecutive pair of numbers in the queue must have some prime as a common factor. So we can start with a prime and then look at pairs that are multiples of that prime. We can then choose a different prime (if a prime is repeated we will have 3 numbers that are divisible by it) that divides the second number, and choose the third number that is a multiple of the new prime, and so we continue until we have all six numbers in the queue.

This recursive Python 3 program is a little longer that my previous approach, but it runs quicker, and can be used to explore solutions for different totals and number of elements in the queue. (It also removes the solutions that that are reverse of another solution). For the parameters of the puzzle it runs in 143ms.

Run:[ @repl.it ]LikeLike

## Robert Brown 5:18 pm

on30 August 2019 Permalink |That’s odd. My QuickBasic program (using a different algorithm!) runs in < 10ms.

LikeLike