**From New Scientist #1408, 3rd May 1984** [link]

It took some hours for the ZX Spectrum I received for Christmas to produce this pretty specimen of an integral-sided square, with a point *P* lying inside it at integral distances from three of the square’s corners.

If you use a computer, it will probably take you just as long to find another such specimen with smaller square-side. But without a computer, it is possible to find a solution in a fraction of the time. *P* must be inside the square, not outside or on the edge.

What is the length of the side of the smaller square and what are the distances *PA*, *PB*, *PC*?

[enigma261]

### Like this:

Like Loading...

*Related*

If we consider the square to be of side

N, and the integer distancesAP,BP,CPto bea,b,crespectively. And let’s assume thata≤b.We choose integers

aandb, such thata≤N/√2, anda≤b≤N√2.Then labelling the angle ∠

ABPasθwe have (applying the cosine rule to triangleABP):which gives:

let’s say:

so:

Now in the triangle BCP:

and:

so:

also:

so:

or (remembering that

y= 2Nb):Now,

cis an integer, soc²is also an integer, so it follows that 2Nbsin(θ) must be an integer, hencey² –x² must be a perfect square, sayz², so (x,z,y) are a Pythagorean triple.So for a given

N, we can chooseaandband see if we get a validc. This Python program checks the possibilities for N from 1 to 52. It runs in 71ms.Solution:The smaller square has sides of 51. The distancesPA,PB,PCare 25, 52, 53.As the setter said it took some hours for a

ZX Spectrumto come up with the square given in the puzzle I thought I would code my program inBBC Basic(using BeebEm3) to see how long it would take to run. This code runs in 10½ minutes (equivalent time on an actualBBC B).Of course, even 10½ minutes is longer than it takes to get the answer by noticing that we can fit the triangles

ABPandBCPinto a 51 × 51 square by joining them along the sides of length 52.Analytic geometry solution without using angles.

Point in the square P(x,y), Square’s side=a

Naim: This code doesn’t seem to find the solution for a square with side 51.

Hi Jim,

Check your figure’s side which is 52.

Here is the output:

Square Side= 52

Three Distances= 25 , 51, 53

Square Side= 52

Three Distances= 53, 51, 25

The output from your program gives the square shown in the diagram in the problem statement (in two different ways).

The puzzle is to find a square with a side

less than52.You should find there is a square of side 51, and the three distances are 25, 52 and 53.

Ok, Jim. No fraction step in ” for loop” in python except list implementation and writing a function for it. The coordinates of the point P(x,y) are approximately x=6,127 and y=24.235 for side length 51.

The horizontal and vertical displacements of P from B are given by:

(N² + b² – c²) / 2N and (N² + b² – a²) / 2N.

When N=52 these are 24 and 45.

But when N=51 they are 416/17 (≈ 24.47) and 780/17 (≈ 45.88), which is why your program didn’t find them. Although the distances PA, PB, PC are integral, the horizontal and vertical displacements of P from the corners are not necessarily integers.

The coordinates I had indicated was for 52, not for 51,

Here are another properties for 52

Square Side= 52

Four İnteger Distances= 25 51 53 53 x= 7 y= 28

Square Side= 52

Four İnteger Distances= 53 51 25 25 x= 28 y= 7