**NOTE: there isn’t a box with very pale text in it below after the fourth paragraph of this post, hold down Shift and click Reload in your web browser. Thanks.**

Many years ago – more than ten, because I was at high school – my maths teacher gave me a problem to occupy myself when I ran out of things to do in my maths lessons. I gave it a whole ten or fifteen minutes attention and then moved on to something more interesting, which, knowing me at the time, was probably staring longingly and hopelessly at Sarah Phoenix. Last night, something – probably that course on number theory on the MIT website, actually – triggered the memory of the problem and I was gripped by a sudden urge to solve it. After a few minutes of tracing on the wall with my finger (I’m a geek, I don’t own any pens), I had a solution, and a proof, and I was happy. So, that’s a nice story. But not a terribly interesting post. So, just so you can share in my joy, I shall outline the problem and the solution for your delight and merriment.

Consider a snooker table with pockets in the four corners only. It has integer dimensions x and y corresponding to the width and the length of the table. A ball is placed at the bottom-left corner of the table and struck so that it travels at 45 degrees to either edge of the table. When the ball hits an edge, it bounces off at exactly 90 degrees. It will continue travelling until it reaches a pocket.

- Prove that the ball will always eventually reach a pocket
- Show how the pocket the ball will end up in can be derived from the dimensions of the table.

Some of you will probably not want the solution spoiling, so the solution below is in very light coloured text. To read it, simply move the mouse cursor over the text.

Throughout this proof, I use “horizontal bounce” to mean a change in horizontal direction – that is, a bounce off the left or right edges of the table – and “vertical bounce” to mean a change in vertical direction – that is, a bounce off the top or bottom edges of the table.

Consider that in one unit of time, the ball will travel one unit horizontally (either left or right) and one unit vertically (either up or down). The ball bounces when it hits an edge. Consider bounces off the top and bottom: as the table is *y* units high, the time taken to travel from the bottom of the table to the top (neglecting horizontal movement, as this is irrelevent for the moment) will be *y* units of time – and thus, it will hit the top or bottom edge every *y* units of time. Similarly, it will hit the left or right edges every *x* units of time.

As the pockets lie at the corners – that is, where the edges of the table meet, the ball can only be at a corner (and therefore go in a pocket) at a point in time that is a multiple of both *x* and *y* – in fact, it will be the *lowest common multiple* of *x* and *y*, as it will enter the pocket on the first occasion the time is at a simultaneous multiple of *x* and *y*. As there is *always* a lowest common multiple of two integers, this therefore proves that the ball will always end up in a pocket.

Now, to show which pocket the ball will end up in: There are four possible directions of travel for the ball, and each corner can only be arrived at by one of these directions of travel – if the ball is travelling down and left, it will end up in the bottom left pocket, and so on. So, if we know the direction the ball is travelling in when it hits the pocket, we know which pocket it has gone in.

When the ball starts off, it is travelling up and to the right. When it hits an edge, it will change either its horizontal direction or its vertical direction. Consider changes in the ball’s vertical direction: the first bounce will change the direction from up to down; the second, from down to up; the third, up to down again, and so on. Thus, we can see that, after an odd number of changes in vertical direction (1,3,5,7…) the direction of the ball will *always* be downwards, and after an even number of vertical-bounces (0,2,4,6…) the direction of the ball will *always* be upwards. Using the same logic, we can show that the horizontal direction of the ball will always be left after an odd number of horizontal bounces, and right after an even number of horizontal bounces.

So, therefore, if we know the number of horizontal and vertical bounces, we know the final direction of the ball, and thus what pocket it has ended up in. So, how do we find the number of bounces? Well, we’ve already shown that the ball will enter the pocket after *t* = LCM(*x*,*y*) units of time, and we know that the ball bounces horizontally every *x* units of time, and vertically every *y* units of time. So, the number of horizontal bounces will be *t*/*x*, and the number of vertical bounces will be *t*/*y*. And thus, we can determine which pocket the ball will end up in:

If *t*/*x* is **odd**, then **left** else **right**.

If *t*/*y* is **odd**, then **bottom** else **top**.

Easy when you know how, eh?