Sunday Times Teaser 2560 – Three Trees
Published: 16 October 2011 (link)
Our front garden is circular, with a diameter less than 100 metres. Three trees grow on the perimeter: an ash, a beech and a cherry, each a different whole number of metres from each of the other two. A straight trellis 84 metres long joins the ash to the beech, and a honeysuckle grows at the point on the trellis nearest to the cherry tree. The distance from the cherry to the ash plus the distance from the ash to the honeysuckle equals the distance from the cherry to the beech.
What is the diameter of the garden?
One Comment
Leave one →
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829303132333435363738394041424344454647from itertools import count# Let the angle at triangle vertex A be alpha. The# diameter of the circumcircle for the triangle ABC# is given by (where A is the trianngle's area):## (1) d = a.b.c / (2.A)## The area A = (1/2).b.c.sin(alpha) now gives:## (2) d = a / sin(alpha)## THe given relationship BC = AC + AH is:## (3) a = b + b.cos(alpha)## Using (2) and (3) to eliminate alpha gives:## (4) d^2 = a.b^2 / (2.b - a)## Using the cosine rule for alpha:## (5) a^2 = b^2 + c^2 - 2.b.c.cos(alpha)## with (3) gives:## (6) (a + c)^2 = (b + c)^2 + c^2# the given value of cc = 84# try increasing b values until (6) gives a perfect square# for a + cfor b in count(1):apc2 = (b + c) ** 2 + c ** 2apc = int(apc2 ** 0.5)a = apc - c# from (4) 2b - a is greater than zeroif apc ** 2 == apc2 and 2 * b - a > 0:# now compute the square of the circumradius from (6)d2, r = divmod(a * b ** 2, 2 * b - a)d = int(d2 ** 0.5)if not r and d * d == d2:fs = 'Diameter = {} (a = {}, b = {}, c = {}).'print(fs.format(d, a, b, c))break