Teaser 3308: New towns
From The Sunday Times, 15th February 2026 [link] [link]
Three new towns (A, B and C) were being built, with straight roads joining them. Each road was a whole number of miles in length, with AB the same as BC and a total length of the three roads of 108 miles.
A new power station was needed for the three towns and two plans were considered. The Plan 1 site at point P was to be the same distance from each town (a perfect square number of miles). The Plan 2 site was to be a whole number of miles along PB such that the total length of cable connecting the power station to each town was a whole number of miles. Given the above, no shorter total cable length of a whole number of miles was possible, so plan 2 was adopted.
What was the total cable length?
[teaser3308]













Jim Randell 9:00 am on 15 February 2026 Permalink |
This Python program runs in 73ms. (Internal runtime is 291µs).
from enigma import (Accumulator, irange, is_triangle, rcs, fdiv, is_square_p, point_dist, intr, printf) # if float <f> is within <t> of integer <i> return <i> def snapf(f, t=1e-6): i = intr(f) if abs(i - f) < t: return i T = 108 # T = AB + BC + AC # choose a value for x (= AB = BC) for x in irange(1, (T - 1) // 2): # calculate y (= AC) y = T - 2*x if not is_triangle(x, x, y): continue # calculate the positions of the towns z = 0.5 * y h = rcs(x, -z) (A, B, C) = ((z, 0), (0, h), (-z, 0)) # P = (0, h - p) is the circumcentre of triangle ABC # distance p = BP must be an integer (and a perfect square) p = snapf(fdiv(x * x, 2 * h)) if not is_square_p(p): continue printf("x={x} y={y} -> h={h} p={p} [A={A} B={B} C={C}]") # find minimum total length of cable r = Accumulator(fn=min, collect=1) # choose a distance along BP (excluding endpoints) to site Q for d in irange(1, p - 1): # calculate total length of cable required Q = (0, h - d) ds = list(snapf(point_dist(Q, X)) for X in [A, B, C]) # distance to each town is an integer if None in ds: continue t = sum(ds) # output scenario printf("-> d={d} Q={Q} ds={ds} t={t}") r.accumulate_data(t, d) # output minimal length printf("minimal length = {r.value} [d={r.data}]") printf()Solution: The total length of cable required is 60 miles.
If we consider A to be 24 miles due east of O, and C to be 24 miles due west of O, then B is 18 miles due north of O.
The distances are AB = BC = 30 miles, AC = 48 miles, total = 108 miles.
The point P is 7 miles due south of O, and so the distances AP = BP = CP = 25 miles.
Plan 2 sites the power station at a point Q that is 10 miles due north of O giving distances:
Other possible positions (along PB) for the power station that give integer distances to each town are:
Note that if the power station were placed at B, then the total amount of cable required would also be the minimum of 60 miles.
And if it were placed at P, then the total amount of cable required would 25 miles to each town = 75 miles.
The absolute minimum amount of cable required is 59.57 miles, with the power station placed at a point 13.86 miles due north of O.
LikeLike
Frits 8:09 am on 16 February 2026 Permalink |
Based on Jim’s program.
Good chance I don’t understand anymore if I will look at it at a later date.
I didn’t check if Plan 2 used a shorter total cable length then Plan 1.
from enigma import is_square, ceil # distance metric between 2 points dist = lambda p, q: ((p[0] - q[0])**2 + (p[1] - q[1])**2)**.5 sol = 99999 # choose a value for x (= AB = BC), y < 2x so 4x > 108 for x in range(28, 54): # calculate y (= AC) y = 108 - 2 * x # calculate height (line B perpendicular to AC) h = 6 * (3 * x - 81)**.5 # calculate the distance p = BP p, r = divmod(x**2, 2 * h) if r or not is_square(p): continue A = (y // 2, 0) # derive points that are an integer distance away from point A sol = min(sol, min(2 * sq + h - n for n in range(ceil(h)) if (sq := is_square((54 - x)**2 + n**2)))) print(f"minimal length = {sol}")LikeLike
Jim Randell 11:56 am on 16 February 2026 Permalink |
@Frits: This doesn’t seem to check all integer points along PB (there should be p − 1 of them, if we exclude the endpoints).
LikeLike
Frits 4:33 pm on 16 February 2026 Permalink |
@Jim, my code is not totally correct.
I had noticed that the distances from Q to A and Q to C in the optimal solution were symmetrical around d=h (fi these distances were the same
for d=h-1 and d=h+1). The distance from Q to B is not symmetrical around d=h but is increasing. This means that if d > h potential new total length of cable will always be higher than the other symmetrical value (at least if p <= 2.h).
That's why I took a shortcut to check fewer entries. That is not always allowed.
LikeLike
Jim Randell 8:07 am on 17 February 2026 Permalink |
@Frits: Fair enough (although does that not assume the intersection of AC and BP is a (half-) integer distance from B and P – is this justified in general?). It just wasn’t clear to me from the code you posted that all possible positions would be considered.
LikeLike
Alex.T.Sutherland 2:32 pm on 18 February 2026 Permalink |
Given:- Towns form an isosceles triangle AB = a; BC = a; AC = b;
Periphery = 2*a + b = 108. b is even;
Plan 1. P is the centre of the circumsbribed circle thro’the towns
and R is the radius (a perfect square ).
The line PB halves AC at D and is perpendicular to AC.
P is distant R from B in the appropriate direction.
Soln:- Using R = a^2 / ( sqrt(4*(a^2) -b^2).
2*a+b = 108.
R is a perfect square.
Solve for R,a,b
(Since b is even use it instead of ‘a’..less nuumber of calcs).
This gives R,a,b,and the postion of P.
The total cable length in Plan 1 = 3*R.
P = site location for Plan 1.
S is the site location on line PB ,integer from P distant x = [1:R] .
For each x calculate Length = 2*AS + BS;
Find integer pairs (x Lx).(I have found 4 such pairs…one is S=B ie x= R).
There are 2 with a minimum length (B being one of them).
The answer is either one.
This does not affect the required answer only where the site is to be located.
Answer: Significantly less than Plan_1 which is 3*R.
Lots of Pythagorean triangles.
Sum of the digits for each of [AS BS CS] are all equal.
(as is the digit product of b/2).
Time :- Aprox. 0.5 ms
LikeLike