Teaser 2548: Planetary line
From The Sunday Times, 24th July 2011 [link] [link]
George and Martha are studying a far-off galaxy consisting of 10 planets circling a sun clockwise, all in the same plane. The planets are Unimus (taking one year to circle the sun), Dubious (two years), Tertius (three years), and so on up to Decimus (10 years).
At one instant today the sun and all 10 planets were in one straight line. Martha said it will be ages before that happens again. “Don’t let’s be greedy,” said George. “How long must we wait until at least nine planets and the sun are in a straight line?”
How long must they wait?
In honour of the current planetary parade.
[teaser2548]





Jim Randell 5:08 pm on 26 February 2025 Permalink |
Assuming the planets are in circular orbits, and they can be aligned on opposite sides of the sun.
If we have a faster planet that makes a half orbit in period x, and a slower planet that makes a half orbit in period y, then, if they are initially in alignment, the time t taken for the fast planet to get one half orbit ahead of the slow planet is given by:
For for any collection of planets we can choose one of the planets, calculate the time taken for it to align with each of the other planets separately, and then calculate the LCM of these values to find the earliest time when they all align.
This Python program runs in 68ms. (Internal runtime is 211µs).
from enigma import (Rational, Accumulator, mlcm, mgcd, subsets, call, arg, printf) Q = Rational() # orbital periods of the planets orbits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] k = arg(9, 0, int) # find the earliest (half-orbit) alignment of the planets <ss> def align(ss): x = ss[0] qs = list(Q(x * y, 2 * abs(x - y)) for y in ss[1:]) # calculate the LCM of the fractions n = call(mlcm, (q.numerator for q in qs)) d = call(mgcd, (q.denominator for q in qs)) return Q(n, d) # find minimal times r = Accumulator(fn=min, collect=1) # consider k sized subsets for ss in subsets(orbits, size=k): # calculate the alignment times for this set t = align(ss) printf("[{ss} -> {t} ({f})]", f=float(t)) r.accumulate_data(t, ss) # output solution printf("min time = {r.value} ({f}) years", f=float(r.value)) for ss in r.data: printf("-> {ss}")Solution: 9 planets and the sun will align after 180 years.
If all the planets start at an angle of 0°, then in 180 years we have the following alignment:
We see that planets 1, 2, 3, 4, 5, 6, 9, 10 are in their original positions, and planet 8 is on the opposite side of the sun (but still in a straight line with the other planets). Planet 7 is the only one that is off the line.
After 1260 years all the planets will have completed a whole number of half-orbits (all except 8 have returned to their original positions, but 8 is on the opposite side of the sun), and after 2520 years (= LCM of 1 .. 10) all the planets have returned to their original positions and the cycle will start again. The cycle of alignments is as follows:
But we can have alignments other than at 0°/180°:
For example the earliest alignment of the 5 planets 1, 3, 5, 7, 9 is after 78.75 years:
They are aligned along 90°/270°.
LikeLike