# Sunday Times Teaser 2592 – Inventive Inventories

*by Simon Massarella*

#### Published: 27 May 2012 (link)

It is known that there is just one 10-figure number that is “self-counting” in the sense that its first digit equals the number of 1s in it, the second digit equals the number of 2s in it, and so on, with the ninth digit equalling the number of 9s in it and the tenth digit equalling the number of 0s in it.

Similarly, a 9-figure number is “self-counting” if its first digit equals the number of 1s in it, the second digit equals the number of 2s in it, and so on, with the ninth digit equalling the number of 9s in it (and with the 0s remaining uncounted).

(a) What is the 10-figure self-counting number?

(b) What is the highest 9-figure self-counting number?

One Comment
Leave one →

This requires quite a bit of programming to obtain a reasonably fast solution. I tried several approaches, some of which wer very fast but didn’t guarantee to reach a solution. The solution here is reasonably fast and provides a more general solution for finding “self-describing” numbers. There are two sequences of such numbers, one in which successive digits from the left count ‘0’s, ‘1’s … and another in which they count ‘1’s, ‘2’s … This program can find both types.