Skip to content

# Sunday Times Teaser 2913 – Return Tickets

### by Victor Bryant

#### Published July 22 2018 (link)

In our tombola the tickets were numbered consecutively from 1 upwards and were printed in books of 20. A local airline donated the prizes — a number of tickets to Paris and back. We decided to split the prizes into single-journey tickets and award them in an unusual way. If any ticket number had all different digits which were in increasing order then it won an outward flight to Paris: if it had all different digits which were in decreasing order then it won a flight back from Paris. So, for example, number 145 won an outward flight, number 30 won a flight back, and single-figure numbers were lucky enough to win tickets there and back. Luckily we had exactly the right number of tickets for all the prizes to be awarded.

How many tickets did we print?

3 Comments Leave one →
1. Brian Gladman permalink

2. Here’s a solution that finds all possible answers for a specified number of tickets per book (which can be given as a command line argument). It does this by collecting increasing and decreasing numbers and then considering them in order.

(Also on repl.it as teaser2913c.py [ https://repl.it/@jim_r/teaser2913 ]).

It turns out there are no solutions larger than 8519, so a basic search of ticket numbers can stop there (and give a program that finds all possible solutions), and my code need only consider numbers of up to 4-digits.

3. Brian Gladman permalink

I also did a version using the approach used by Jim above: