Ready to test your little grey cells? Imperial’s best minds set the ultimate puzzle challenge.


1: Hard

I have nine coins in my pocket. Some of these are 2p pieces and the others are 5p pieces. I am contemplating buying some buns. I notice that I can buy four buns without requiring any change but, although I can afford them, I do not have the coins to buy five buns without needing to get change. How much does a bun cost and how many coins are there of each type?

Dr Lynda White, Principal Teaching Fellow in Experimental Design, Department of Mathematics

See the answer

See the answer

Solution: A bun costs six pence and there are 4 two pence coins (and 5 five pence coins).

We can infer from the wording of the question that the number of two pence coins is one of 2, 3, 4, 5, 6 or 7, and correspondingly 7, 6, 5, 4, 3 or 2 for five pence coins.

We are looking for a total value of coins which is a multiple of 5 but which cannot be attained exactly using the two and five piece coins and which therefore require change. In addition, the corresponding multiple of 4 must be attainable exactly.

When the number of two pence coins is 2, 5, 6 or 7, a straightforward check shows that all total costs which are affordable multiples of 5 can be attained exactly so we do not have a solution here.

When the number of two pence coins is 3, all total costs which are affordable multiples of 5 can be attained exactly except for 35. This would lead to a bun price of 7 pence but 28 pence (which would be the cost of 4 buns) is also not attainable. Again, there is no solution.

However, when there are 4 two pence coins we find that all total costs which are affordable multiples of 5 can be attained exactly except for 30. This leads to a bun price of 6 pence and we see that 24 pence (=2+2+5+5+5+5), the price of 4 buns, can be attained exactly. This is the only solution.


2: Very hard

I keep all my worldly wealth in a numbered Swiss bank account. Recently, the bank decided that all account numbers must have between 30 and 80 digits and may not start with a zero. It's complicated, but I can work mine out each time I need it. If I multiply my number by nine I get the same number with the last digit shifted to the front (so that, for example, 134689 would become 913468). Can you help me work out my account number?

Professor Jonathan Mestel, Professor of Applied Mathematics, Department of Mathematics

See the answer

See the answer

Solution: 10112359550561797752808988764044943820224719

Digit by digit construction:

If an integer has the same number of digits when it is multiplied by 9, it must start with a 1. Its next digit must be either a 0 or a 1. However 11… would give 99… when multiplied by 9 which wouldn’t work, as putting a 9 in front would give 911… So the only possibility is that the first two digits are 10:

First two digits are 10

and the product must begin with a 9. This means the last digit is 9. When we multiply by 9 we find 9*9 = 81 so the last digit of the product must be 1, carrying 8 towards the next digit and

The last two digits are 19.

Continuing in this manner we have 9 x 1 + carry over 8 = 7 carry 1, 9 x 7 + 1 = 4 carry 6 so that

The last 4 digits are 4719.

Continuing the backwards construction, we have

9 x 4 + 6 (carried over) = 42 = 2 carry 4

9 x 2 + 4 (carried over) = 2 carry 2

9 x 2 + 2 (carried over) = 0 carry 2

9 x 0 + 2 (carried over) = 2 carry 0

So currently we have 9 x 10………20224719 =  910……..2022471

….and carrying on in this manner  (9x2 +0 = 8 carry 1 etc) we eventually find the solution of 44 digits:


Incidentally, instead of terminating after 44, we could have continued the process, going round the loop once more. This would duplicate the 44 digit string giving us an 88 digit solution. 1011235955056179775280898876404494382022471910112359550561797752808988764044943820224719. But this is too large for the bank’s specifications, thank goodness.

Construction of entire integer

To construct an integer with the required multiplication property, call it x and suppose it has k digits, with a last digit N. Then removing the last digit is equivalent to subtracting N and dividing by 10. We then put N at the front which is adding N x 10k-1. We deduce that

9x= (x-N)/10 + N(10k-1)

Or 90x = x-N +N(10k )

And solving for x

x = N(10k-1) / 89

This requires 10k - 1 to be divisible by 89. Using “Fermat’s Little Theorem”, since 89 is prime, this happens for k = 88 (and possibly for smaller values of k which divide 88). We know N = 9 giving a possible solution

x = 9(1088-1)/89 = 1011235955056179775280898876404494382022471910112359550561797752808988764044943820224719

However 88 digits is too long given the specification.

By inspection, we spot the smaller solution 10112359550561797752808988764044943820224719.

Note (1088-1) = (1044-1)(1044 + 1) and 1044 + 1 = 1000000……001 which on multiplication appends a 44 digit number to itself. So provided 89 divides 1044 - 1 and not 1044 + 1, we have a smaller solution.


3: Fiendish

A medieval farmer is in their house and needs to get water from a river and then take the water to animals in a barn. The farmer would like to take the shortest route to the barn, but doesn’t know about calculus (as it hasn’t yet been invented). The farmer’s house is 400 yards west of the river, which runs north-south, and the barn is 200 yards west of the river, but 800 yards further north than the house. How can the farmer work out the shortest path, and how long will that path be?

Dr Daniel Mortlock, Lecturer in Astro-Statistics, Department of Physics

See the answer

See the answer

Solution: 1000 yards

There are several ways to solve this problem that don’t involve calculus.  The simplest is to imagine a "copy" of the barn that is at the same north-south position (i.e., 800 yards north of the farm) but 200 yards to the *east* of the river.  The quickest route is then, obviously (at least assuming the farmer knows about Euclid) a straight line from the house to the “copy” barn.  The implied path to the real barn is then like the farmer “bouncing” off the river like light off a mirror.  The distance is given by Pythagoras’s theorem as [(400 yards + 200 yards)^2 + (800 yards)^2]^(1/2) = 1000 yards.  (It’s actually a classic “3-4-5” triangle, albeit a bit disguised.)