### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,123)
- misc (2)
- project euler (2)
- puzzle (31)
- site news (43)
- tantalizer (31)
- teaser (3)

### Site Stats

- 168,282 hits

Programming Enigma Puzzles

12 December 2016

Posted by on **From New Scientist #1523, 28th August 1986** [link]

Mr Bagel was intrigued when approached by Mr Bola selling raffle tickets, for he had never taken part in a raffle.

“I see that each ticket in your book has the same number of digits on it, the first having a number of zeros followed by a one, and the number on each successive ticket increasing by one.”

“That’s true,” replied Bola. “I haven’t sold any yet. Perhaps that’s because there is to be only one winning ticket.”

“Now tell me, Tom,” asked Bagel, “what happens if a ticket number is composed entirely of invertible digits, namely 0, 1, 8, 6 or 9, so that is also forms a number when viewed upside down?”

“In a draw we always read the tickets out with the perforation on the left,” replied Bola.

“That’s a pity, otherwise one could buy two numbers for the price of one ticket.”

Bagel, being superstitious, chose a ticket with an invertible number. One way up the number was divisible by all the even digits, and the other way up it was divisible by all the odd digits. Moreover, when his ticket number was multiplied by a digit (I forget which), the product was the number of the last ticket in the book, a number in which none of the digits was invertible.

I forget whether he won the draw, or even what the draw was for. But, given the chances of his winning were better than one in 100,000, what was the number on the last ticket in the book?

[enigma374]

Advertisements

%d bloggers like this:

The chances of winning are less than 1 in 100,000, so the number of digits in the numbers on the tickets is 5 or less.

This Python program runs in 69ms.

Solution:The number of the last ticket in the book is 77544.Bagel’s ticket was number 08616.

8616 is divisible by 2, 4, 6, 8.

91980 is divisible by 3, 5, 7, 9.

Without the constraint on the chances of winning, we get further solutions starting with 8 digit tickets:

It seems that the 1 in 100,000 chance of winning was intended to limit the number of digits in tickets to five in order to give a unique solution as reported by Jim. However the six digit ticket number 011088 (880110 reversed) gives a lower answer of 44352 for the final ticket.

If we allow all the ticket numbers to be padded with leading zeros we get two families of solutions:

(1) The last ticket in the book is number 77544, and Bagel’s ticket is number 8616. The number printed on each ticket is padded with a number of zeros to make whatever digit length (≥ 5) we require.

(2) The last ticket in the book is number 44352, and Bagel’s ticket is number 11088. Again, the number printed on each ticket is padded with zeros to make whatever digit length (≥ 6) we require.

And as the ticket numbers get longer we get further families of solutions.

Although in all these cases the number on the inverted ticket is larger than the number of the final ticket, so maybe we should not really consider them to be “two tickets for the price of one” (as one of the numbers can never win). But if we consider that then there is no solution to the puzzle.

I took the view that the lower number tickets were zero padded to bring them up to the same digit length as the final ticket, but that the final ticket was not itself padded with zeros.

This gives us the unique solution given above, so is probably what the setter had in mind.

But the wording in the puzzle could have been clearer to eliminate the additional solutions.