## A simple programming challenge

### Background

Around 1981, a British computer magazine (Personal Computer World) had a programming contest and this was one of the puzzles.

There are many 9-digit integers in the range 123456789 to 987654321 where each digit only ever appears once. What is the 100,000th number in this sequence?

### Example

The first number is 123456789, the second is 123456798, the third is 123456879 and so on. No digit can repeat so 122345675 is not a valid number in this sequence.

The problem was “Write a program in C or C++ that outputs the 100,000th number as fast as possible. Use any algorithm, except you cannot pre-calculate the answer and then write a program that just prints the result (Somebody actually tried it). Your entry must calculate the number!”.  I’ll give this a month so the deadline is August 14th 2020. Please don’t copy any of the existing answers- you can with a bit of poking around and yesterday’s blog entry find some answers to this.

### Prize?

Er fame and glory and a mention on here!

### Note

It’s possible to solve this by hand. I did, back in 1981. It took me 20 minutes with a pen and paper. I also wrote a 6502 assembly language version of it than ran on a Vic-20. It took something like 10 hours to count up to the correct answer.

## The Wayback machine-slightly offtopic

There is a wonderful website (archive.org) that makes a backup of websites. It even has one of this blog, taken on April 30th. It’s remarkable.

The reason I mention it is because I was looking at the backup of cplus.about.com, a website that I managed (curated, wrote tutorials etc.) on “Programming in C, C++, C#” (and even Go) between 2006 and 2013.  One of the things I ran there was a set of programming challenges and by the end I’d done a whopping 70 of them. I came up with the idea, published it, then adjudicated entries.

This page has a list of 65 of them.  There may be more from a later date but no more than 70.

As I can now gain access to most of them, I’m going to rerun a few here. starting with the first which I’ll publish tomorrow.