Brain-Teaser 454: Nine holes
From The Sunday Times, 25th January 1970 [link]
The card of the course at Triangle Park Golf Club gives the total length of the first 9 holes as 3,360 yards. Par for the individual holes (numbers 1 to 9 respectively) being 5, 4, 5, 4, 3, 4, 4, 3, 5 (total 37).
Closer inspection of the card would show that the lengths of the holes (each a whole number of yards) are such that holes 1, 2 and 3 could each form a different side of the same right-angled triangle (Triangle A) and that other right-angled triangles could similarly be formed from lengths equal to those of holes 4, 5 and 6 (Triangle B); 7, 8 and 9 (Triangle C); 1, 4 and 7 (Triangle X); 2, 5 and 8 (Triangle Y) and 3, 6 and 9 (Triangle Z).
Moreover, the total length of the three holes forming Triangle A, the total length of the three holes forming Triangle B, and the total length of the three holes forming Triangle C could similarly form the three sides of another right-angled triangle (Triangle ABC) while yet another right-angled triangle could similarly be constructed from the total lengths of the holes forming triangles X, Y and Z (Triangle XYZ).
In triangle ABC the sides would be in the ratio 5:3:4.
The length of each of the par 3 holes is between 150 and 250 yards (one being 168 yards); the par 4 holes are between 250 and 450 yards; and the par 5 holes are between 475 and 600 yards (one being 476 yards).
What are the lengths of holes 2, 6 and 7?
This puzzle is included in the book Sunday Times Brain Teasers (1974).
[teaser454]
Jim Randell 10:33 pm on 21 February 2019 Permalink |
This Python program uses the [[
pythagorean_triples()]] function from the enigma.py library to find appropriate triangles. (Originally written for Teaser 2910).Run: [ @replit ]
from enigma import (defaultdict, pythagorean_triples, sq, printf) # par for distance x def par(x): if 149 < x < 251: return 3 if 249 < x < 451: return 4 if 474 < x < 601: return 5 # find triangles in the appropriate classes ts = defaultdict(list) for t in pythagorean_triples(600): k = tuple(par(x) for x in t) if None not in k: ts[k].append(t) # select tuples from d[k] ordered by indices in ss def select(d, k, ss): for x in d[k]: for s in ss: yield tuple(x[i] for i in s) # does (x, y, z) form a right-angled triangle def is_triangle(x, y, z): return sq(x) + sq(y) + sq(z) == 2 * sq(max(x, y, z)) # choose triangle A (5, 4, 5) for (d1, d2, d3) in select(ts, (4, 5, 5), [(1, 0, 2), (2, 0, 1)]): # choose triangle B (4, 3, 4) for (d4, d5, d6) in select(ts, (3, 4, 4), [(1, 0, 2), (2, 0, 1)]): # choose triangle C (4, 3, 5) for (d7, d8, d9) in select(ts, (3, 4, 5), [(1, 0, 2)]): # check the total distance if not (sum((d1, d2, d3, d4, d5, d6, d7, d8, d9)) == 3360): continue # check the other triangles (X, Y, Z) = ((d1, d4, d7), (d2, d5, d8), (d3, d6, d9)) ABC = (d1 + d2 + d3, d4 + d5 + d6, d7 + d8 + d9) XYZ = (d1 + d4 + d7, d2 + d5 + d8, d3 + d6 + d9) if not all(is_triangle(*t) for t in (X, Y, Z, ABC, XYZ)): continue # check ABC is a 3, 4, 5 triangle if not (5 * min(ABC) == 3 * max(ABC)): continue # check the given pars if not (168 in (d5, d8) and 476 in (d1, d3, d9)): continue printf("d1={d1} d2={d2} d3={d3} / d4={d4} d5={d5} d6={d6} / d7={d7} d8={d8} d9={d9}")Solution: Hole 2 is 280 yards. Hole 6 is 357 yards. Hole 7 is 420 yards.
There is only one solution:
In fact if the triangle constraints for A, B, C, X, Y, Z, ABC, XYZ are satisfied, there is only a single solution even if the conditions for the total distance, ratios for ABC, and the specific distances for par 3 and 5 are ignored (lines 38, 47, 50).
LikeLike
Jim Randell 9:53 am on 23 February 2019 Permalink |
This puzzle is a good candidate for solving with a declarative set of constraints.
Here is a MiniZinc model, that is run via the minizinc.py module. It solves the puzzle in 93ms.
%#! python3 -m minizinc use_embed=1 % hole distances {var("150..250", ["d5", "d8"])}; % par 3 {var("250..450", ["d2", "d4", "d6", "d7"])}; % par 4 {var("475..600", ["d1", "d3", "d9"])}; % par 5 % total distance constraint d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 = 3360; % right angled triangle constraints predicate is_triangle(var int: a, var int: b, var int: c) = pow(a, 2) + pow(b, 2) + pow(c, 2) = pow(max([a, b, c]), 2) * 2; constraint is_triangle(d1, d2, d3); % triangle A constraint is_triangle(d4, d5, d6); % triangle B constraint is_triangle(d7, d8, d9); % triangle C constraint is_triangle(d1, d4, d7); % triangle X constraint is_triangle(d2, d5, d8); % triangle Y constraint is_triangle(d3, d6, d9); % triangle Z constraint is_triangle(d1 + d2 + d3, d4 + d5 + d6, d7 + d8 + d9); % triangle ABC constraint is_triangle(d1 + d4 + d7, d2 + d5 + d8, d3 + d6 + d9); % triangle XYZ % ABC is a 3, 4, 5 triangle constraint 5 * min([d1 + d2 + d3, d4 + d5 + d6, d7 + d8 + d9]) = 3 * max([d1 + d2 + d3, d4 + d5 + d6, d7 + d8 + d9]); % some lengths are given constraint d5 = 168 \/ d8 = 168; % par 3 constraint d1 = 476 \/ d3 = 476 \/ d9 = 476; % par 5 solve satisfy;LikeLike
GeoffR 11:07 am on 23 February 2019 Permalink |
LikeLike