A Selfish Number
Here’s what I call the `selfish’ number problem:
Find a ten digit number
which satisfies the condition that there are
occurences of the digit
in the number.
This was a fun problem, although I had trouble getting what it was asking for at first— for some reason, I imagined the digits weren’t repeatable, but that makes the problem obviously impossible. Then I tried constructing a list of how many times each digit could possibly occur (e.g. no digit can occur 9 times), and cross referencing the lists to form a number that works.
Ironically, I didn’t get the problem until after I had wrote a code to exhaustively test all ten digit numbers, using brute force (yep, searching
numbers). I said, yeah that’s a lot of numbers, but still, this can be done in a reasonable amount of time… ha ha. When I realized not, I ended up trying basically the same list construction that I mention before, to optimize the number space being searched (e.g. the for loop that determined
doesn’t have to go all the way from 0 to 9). In doing this, I found the answer.
I didn’t realize it at the time, but the answer is obviously unique. I think I was doing this around 1 in the morning, and was already dead exhausted before starting, so I forgive myself.
Possibly relevant posts:
- A hard digit problem (12/30/2004)
- Eukleides (1/16/2004)
- Driver’s Safety (3/20/2005)
which satisfies the condition that there are
occurences of the digit
in the number.