All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 A billiard challenge (Posted on 2008-06-23)
My goal is to pot balls A and B into the pockets numbered 1 and 2 in the billiard table below (diagram at left), using the cue ball O with only two strikes in it.

To do this, my first shot is to strike the cue ball to the point "d"; the cue ball mirror-reflects to the point "f" and strikes the ball B, which falls into pocket 1. The cue ball is now in the position of the potted ball B (diagram at right).

Next, to pot ball A, I strike the cue ball to the point "l". The cue ball mirror-reflects to the point "o", strikes the ball A that mirror-reflects in the point "b" and is potted in pocket 2.

```         a   b   c   d   e                a   b   c   d   e
+---+---+---+---+---+---+        +---+---+---+---+---+---+
|   |   |   |   |   |   |        |   |   |   |   |   |   |
p +---A---O---+---+---+---+ f    p +---A---+---+---+---+---+ f
|   |   |   |   |   |   |        |   |   |   |   |   |   |
o +---+---+---+---B---+---+ g    o +---+---+---+---O---+---+ g
|   |   |   |   |   |   |        |   |   |   |   |   |   |
n +---+---+---+---+---+---+ h    n +---+---+---+---+---+---+ h
|   |   |   |   |   |   |        |   |   |   |   |   |   |
1---+---+---+---+---+---2        1---+---+---+---+---+---2
m   l   k   j   i                m   l   k   j   i               ```
How must you proceed to pot the balls A, B, C, and D, each one in each of the 4 pockets shown (1-2-3-4), with 4 strikes in the cue ball?
```                       a   b   c   d   e
1---+---+---+---+---+---2
|   |   |   |   |   |   |
p +---+---+---A---B---O---+ f
|   |   |   |   |   |   |
o +---+---C---+---+---+---+ g
|   |   |   |   |   |   |
n +---+---+---+---D---+---+ h
|   |   |   |   |   |   |
+---+---+---3---+---+---4
m   l       j   i     ```
The balls A, B, C and D may never touch each other, and the order of potting the balls and where is up to you. And, in your shots, you can only strike the cue ball to another ball or to the points marked in the table.

 See The Solution Submitted by pcbouhid Rating: 3.5000 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution: 8 ways Comment 4 of 4 |

There are 8 ways of doing this. Each row below represents one of the ways. Within each row there are four groups of three characters. Within each of the groups, the first represents the direction the cue ball is aimed: a-p (edge spots) or A-D (balls). The second character is the ball that is struck and sunk. The third character is the pocket in which it's sunk.

`aA3 dC1 BB2 bD4`
`aA3 dC1 DD4 lB2`
`cA3 dC1 BB2 bD4`
`cA3 dC1 DD4 lB2`
`lA4 dC1 BB2 cD3`
`lA4 dC1 BB2 eD3`
`lA4 dC1 BB2 hD3`
`lA4 dC1 BB2 mD3`

Praneeth's solution is the 6th one listed above.

Dej Mar's two solutions are the 7th and 4th ones above.

DECLARE FUNCTION gcd! (x!, y!)
DECLARE SUB try ()
DIM SHARED grid\$(4, 6), p\$(4, 6), lvl, h\$(4)

DIM SHARED edgeX(15), edgeY(15), edgeName\$(15)

CLS

DATA a,0,1
DATA b,0,2
DATA c,0,3
DATA d,0,4
DATA e,0,5
DATA f,1,6
DATA g,2,6
DATA h,3,6
DATA i,4,5
DATA j,4,4
DATA l,4,2
DATA m,4,1
DATA n,3,0
DATA o,2,0
DATA p,1,0

FOR i = 1 TO 15
READ edgeName\$(i), edgeY(i), edgeX(i)
NEXT

DIM SHARED pockX(4), pockY(4)
DATA 0,0, 0,6, 4,3, 4,6
FOR i = 1 TO 4
p\$(pockY(i), pockX(i)) = LTRIM\$(STR\$(i))
NEXT

DIM SHARED ballX(4), ballY(4), cueX, cueY

DATA 1,3, 1,4, 2,2, 3,4

FOR i = 1 TO 4
grid\$(ballY(i), ballX(i)) = MID\$("ABCD", i, 1)
NEXT

cueX = 5: cueY = 1
grid\$(cueY, cueX) = "O"

lvl = 1

try

END

FUNCTION gcd (x, y)
IF x = 0 THEN gcd = ABS(y): EXIT FUNCTION
IF y = 0 THEN gcd = ABS(x): EXIT FUNCTION
num = ABS(x): den = ABS(y)
DO
rmnd = num - den * (num \ den)
IF rmnd = 0 THEN
gcd = den: EXIT FUNCTION
END IF
num = den: den = rmnd
LOOP
END FUNCTION

SUB try
FOR i = 1 TO 15
dx = edgeX(i) - cueX: dy = edgeY(i) - cueY
g = gcd(dx, dy)
dx = dx / g: dy = dy / g
saveDX = dx: saveDY = dy
x = cueX: y = cueY
foundX = 0: foundY = 0
good = 1
DO
x = x + dx: y = y + dy
IF x <= 0 THEN x = ABS(x): dx = -dx
IF y <= 0 THEN y = ABS(y): dy = -dy
IF x >= 6 THEN x = 6 - (x - 6): dx = -dx
IF y >= 4 THEN y = 4 - (y - 4): dy = -dy
IF y = 0 AND (x = 0 OR x = 6) OR y = 4 AND (x = 3 OR x = 6) THEN
IF grid\$(y, x) > "" THEN good = 0: EXIT DO
IF foundX = 0 AND foundY = 0 THEN good = 0: EXIT DO
grid\$(y, x) = grid\$(foundY, foundX)
grid\$(foundY, foundX) = "O"
grid\$(cueY, cueX) = ""
saveCueX = cueX: saveCueY = cueY
cueX = foundX: cueY = foundY
ballNo = INSTR("ABCD", grid\$(y, x))
ballX(ballNo) = -x: ballY(ballNo) = -y
EXIT DO
ELSE
IF grid\$(y, x) > "" THEN
IF foundX OR foundY THEN good = 0: EXIT DO
IF grid\$(y, x) = "O" AND dx = saveDX AND dy = saveDY THEN good = 0: EXIT DO
IF grid\$(y, x) <> "O" THEN foundX = x: foundY = y
END IF
END IF
LOOP

IF good THEN
h\$(lvl) = edgeName\$(i) + grid\$(y, x) + p\$(y, x) + " "
IF lvl = 4 THEN
FOR hSub = 1 TO 4
PRINT h\$(hSub);
NEXT
PRINT : PRINT
ELSE
lvl = lvl + 1
try
lvl = lvl - 1
END IF
grid\$(foundY, foundX) = grid\$(y, x)
grid\$(y, x) = ""
ballX(ballNo) = foundX: ballY(ballNo) = foundY
cueX = saveCueX: cueY = saveCueY
grid\$(cueY, cueX) = "O"
END IF

NEXT i

FOR i = 1 TO 4
IF ballX(i) > 0 AND ballY(i) > 0 THEN
dx = ballX(i) - cueX: dy = ballY(i) - cueY
g = gcd(dx, dy)
dx = dx / g: dy = dy / g
saveDX = dx: saveDY = dy
x = cueX: y = cueY
foundX = 0: foundY = 0
good = 1
DO
x = x + dx: y = y + dy
IF x <= 0 THEN x = ABS(x): dx = -dx
IF y <= 0 THEN y = ABS(y): dy = -dy
IF x >= 6 THEN x = 6 - (x - 6): dx = -dx
IF y >= 4 THEN y = 4 - (y - 4): dy = -dy
IF y = 0 AND (x = 0 OR x = 6) OR y = 4 AND (x = 3 OR x = 6) THEN
IF grid\$(y, x) > "" THEN good = 0: EXIT DO
IF foundX = 0 AND foundY = 0 THEN good = 0: EXIT DO
grid\$(y, x) = grid\$(foundY, foundX)
grid\$(foundY, foundX) = "O"
grid\$(cueY, cueX) = ""
saveCueX = cueX: saveCueY = cueY
cueX = foundX: cueY = foundY
ballNo = INSTR("ABCD", grid\$(y, x))
ballX(ballNo) = x: ballY(ballNo) = y
EXIT DO
ELSE
IF grid\$(y, x) > "" THEN
IF foundX OR foundY THEN good = 0: EXIT DO
IF grid\$(y, x) = "O" AND dx = saveDX AND dy = saveDY THEN good = 0: EXIT DO
IF grid\$(y, x) <> "O" THEN foundX = x: foundY = y
END IF
END IF
LOOP

IF good THEN
h\$(lvl) = MID\$("ABCD", i, 1) + grid\$(y, x) + p\$(y, x) + " "
IF lvl = 4 THEN
FOR hSub = 1 TO 4
PRINT h\$(hSub);
NEXT
PRINT : PRINT
ELSE
lvl = lvl + 1
try
lvl = lvl - 1
END IF
grid\$(foundY, foundX) = grid\$(y, x)
grid\$(y, x) = ""
ballX(ballNo) = foundX: ballY(ballNo) = foundY
cueX = saveCueX: cueY = saveCueY
grid\$(cueY, cueX) = "O"
END IF
END IF
NEXT i

END SUB

 Posted by Charlie on 2008-06-23 15:49:43

 Search: Search body:
Forums (0)