Teaser 3295: Always as the crow flies
From The Sunday Times, 16th November 2025 [link] [link]
I have a map showing the location of four castles. All of the distances between the castles are different two-digit whole numbers of miles, as the crow flies. Alton is due north of Sawley; Derry is furthest west. Fenwick is due east of Derry. Alton and Derry are the shortest distance apart, while the distance from Alton to Sawley is the largest possible to comply with all the other information.
Again, as the crow flies:
How far is a round trip of the castles (A to F to S to D to A)?
“As the crow flies” refers to the shortest (i.e. straight line) distance between two points.
[teaser3295]





Jim Randell 11:15 am on 16 November 2025 Permalink |
The following code generates candidate orthodiagonal quadrilaterals [@wikipedia] with distinct 2-digit values for the sides (AD, AF, DS, FS), and also distinct 2-digit diagonals (AS, DF) such that AS is the largest possible value for the given sides. From these candidates we can then choose those with the maximum possible vertical diagonal (AS).
I added the [[
triangle_height()]] function to the enigma.py library.It runs in 437ms. (Internal runtime is 363ms).
from enigma import (enigma, Accumulator, irange, subsets, divisors_pairs, sq, div, printf) Q = enigma.Rational() # set parameters for triangle_height(), is_triangle(), as_int() is_square_q = enigma.partial(enigma.is_square_q, F=Q) triangle_height = enigma.partial(enigma.triangle_height, div=Q, sqrt=is_square_q) is_triangle = enigma.partial(enigma.is_triangle, fn=enigma.gt(0)) as_int = enigma.partial(enigma.as_int, default=None) # generate candidate orthodiagonal quadrilaterals def generate(): # choose the shortest side (AD) and an adjacent side (DS) for (AD, DS) in subsets(irange(10, 99), size=2): # calculate distances for the other two sides [AD^2 + FS^2 = AF^2 + DS^2] for (x, y) in divisors_pairs(sq(DS) - sq(AD)): (AF, FS) = (div(y - x, 2), div(x + y, 2)) if (not AF) or (not FS) or not (AD < AF < 100 and AD < FS < 100): continue if len({AD, DS, AF, FS}) != 4: continue # look for max AS that gives an integer DF for AS in irange(min(AD + DS, AF + FS, 99), AD + 1, step=-1): # calculate DF x1 = triangle_height(AS, AD, DS) x2 = triangle_height(AS, AF, FS) if (not x1) or (not x2): continue DF = as_int(x1 + x2) if (not DF) or not (AD < DF < 100): continue if len({AD, DS, AF, FS, AS, DF}) != 6: continue # check triangles; use [[ fn=enigma.ge(0) ]] above to allow co-linearity tris = [(AS, AD, DS), (AS, AF, FS), (DF, AD, AF), (DF, DS, FS)] if not all(is_triangle(*ss) for ss in tris): continue # return (<sides>, <diags>) yield ((AD, DS, AF, FS), (AS, DF)) break # we only need the maximal AS # look for maximal vertical diagonal (AS) r = Accumulator(fn=max, collect=1) printf("sides = (AD, DS, AF, FS), diags = (AS, DF)") for (ss, ds) in generate(): p = sum(ss) r.accumulate_data(ds[0], (ss, ds, p)) printf("sides = {ss}, diags = {ds} -> perimeter = {p} [{r.count}]") # output solution printf("\nmax AS = {r.value}") for (ss, ds, p) in r.data: printf("sides = {ss}, diags = {ds} -> perimeter = {p}")I suspect the setter intends no three of the castles to be co-linear (even though this condition is not mentioned in the puzzle text). But if we want to allow such arrangements, we can use [[
fn=enigma.ge(0))]] in line 8. However this gives multiple maximal configurations.Solution: The round trip is 234 miles long.
Assuming no three of the castles are co-linear, there are 11 possible arrangements, and the maximum value of AS is 84:
The diagonals are divided into 84 = 24 + 60 and 77 = 32 + 45, so the quadrilateral is composed of four Pythagorean triangles:
There are 4 candidate convex quadrilaterals (which are also cyclic), the one given in the answer, and its reflection in a NW-SE line (so the diagonals are AS = 77, DF = 84).
The other is:
This can also be mirrored in a NW-SE line to give a further candidate (with diagonals AS = 56, DF = 63).
These sides also give a concave quadrilateral with diagonals AS = 33, DF = 56, but obviously this does not have the longest possible AS distance for these sides. (In fact this is the only arrangement of sides that gives multiple integer AS values).
The other 9 candidate solutions are concave. And the largest AS value among these is:
This arrangement is not composed of Pythagorean triangles.
However, if we allow three of the castles to be co-linear then there are an additional 51 possible arrangements to give a total of 62 candidate arrangements. And there is an additional solution where AS = 84, where the round trip is 224 miles long:
This arrangement is composed of two Pythagorean triangles: (13, 84, 85) and (35, 84, 91) = 7×(5, 12, 13).
The published answer is just: “234 miles”.
LikeLike