My pal is very fond of puzzles, but can't always remember all the details correctly. Yesterday he told me about a new version of the famous 9hole golf problem.
‘OK, there’s this guy, and when he plays golf, he always uses one of 2 shots. He always aims straight for the hole; if he overshoots, then he plays back towards the hole with his next stroke…'
‘Yes, I get the idea. You’re saying that he has a drive of, say, x yards, and an approach shot of, say, y yards, some exact combination of x's and y's will always enable him to sink the ball. What are the lengths of the holes?’
‘Gosh, that’s the problem! I can only remember 4 for certain; 150 – that was the shortest  200, 350, and the longest one was 500.’
‘And what do you ‘remember’ the rest were, old buddy?’
‘Hmmm, something like 180, 280, 300, 370, and 410  but now I come to think about those numbers, I’m pretty certain that one or two of them are wrong.’
‘And how many strokes altogether?’
‘Hehe, that was what you had to work out – but none of the holes was less than 150 yards, and none took more than 5 shots.’
Can anyone tell me what the correct lengths of the 9 holes were, so that I can work out the original problem?
The drive and approach shot lengths ae 130 and 20 yards. With those lengths, the following distances to the hole are achievable in five shots or fewer, assuming the drive(s) is/are always in the forward direction, but the approach shots may be in either direction:
drives app.shots distance
0 0 0
0 1 20
0 2 40
1 4 50
0 3 60
1 3 70
0 4 80
1 2 90
0 5 100
1 1 110
1 0 130
1 1 150 *
1 2 170
1 3 190
2 3 200 *
1 4 210
2 2 220
2 1 240
2 0 260
2 1 280 *
2 2 300 *
2 3 320
3 2 350 *
3 1 370 *
3 0 390
3 1 410 *
3 2 430
4 1 500 *
4 0 520
4 1 540
5 0 650
0 5 100
0 1 20
0 2 40
0 3 60
0 4 80
I've marked the distances mentioned in the puzzle with *'s.
The above table itself is the result of sorting the output of:
' known lengths
DATA 150,200,350,500
' at least 3 of these, but not all:
DATA 180,280,300,370,410
CLS
FOR i = 1 TO 4: READ certain(i): NEXT
FOR i = 1 TO 5: READ maybe(i): NEXT
FOR l1 = 100 TO 500
FOR l2 = 1 TO 200
good = 1
FOR i = 1 TO 4
did = 0
FOR a = 0 TO 2 * certain(i) / l1
b = INT((certain(i)  a * l1) / l2)
IF a * l1 + b * l2 = certain(i) AND a + ABS(b) <= 5 THEN did = 1: EXIT FOR
NEXT
IF did = 0 THEN good = 0: EXIT FOR
NEXT
IF good THEN
goodCt = 0
FOR i = 1 TO 5
did = 0
FOR a = 0 TO 2 * maybe(i) / l1
b = INT((maybe(i)  a * l1) / l2)
IF a * l1 + b * l2 = maybe(i) AND a + ABS(b) <= 5 THEN did = 1: EXIT FOR
NEXT
goodCt = goodCt + did
NEXT
IF goodCt >= 3 AND goodCt < 5 THEN
PRINT l1, l2
FOR a = 0 TO 5
FOR b = 0 TO 5  a
PRINT a; b, a * l1 + b * l2
PRINT a; b, a * l1  b * l2
NEXT
NEXT
END IF
END IF
NEXT
NEXT
where the first line of its output indicates the drive is 130 yards and the approach shot is 20 yards.
The only question remaining is: Which of 170, 190, 210, 220, 240, 260, 320, 390 or 430 is the proper replacement for the erroneously cited 180.
With any of the hole distances, there is only one way of achieving that distance with the 130 and 20 lengths, so the original problem would be solvable with any one of them. They have different stroke counts and so we can't even say what that strokecount answer would have been.
So the answer would seem to be "No; no one can tell you all the correct lengths."

Posted by Charlie
on 20100601 18:30:08 