All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Self-Referential Numbers (Posted on 2005-09-23) Difficulty: 3 of 5
A nine digit number has the property where the first digit equals the number of zeros and ones used in the number, the second digit equals the number of ones and twos used in the number, the third digit equals the number of twos and threes used in the number, etc. through the ninth digit equals the number of eights and nines used in the number. What could the number be?

A ten digit number has a similar property to the nine digit number. The first digit equals the number of zeros and ones used in the number, the second digit equals the number of ones and twos used in the number, etc. through the ninth digit. And also, the tenth digit equals the number of zeros and nines used in the number. What could this number be?

See The Solution Submitted by Brian Smith    
Rating: 3.4000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re(2): Attn: Ken Haley | Comment 14 of 19 |
(In reply to re: Attn: Ken Haley by Penny)

But that only works because the sum of the 10-digit solution happens to be exactly 20.  In other words, what you've done is set i10 = 20 - sum(i1 to i9).  Do we know this has to be the case?  If so, do we know the sum of the digits in all 9-digit solutions has to be 15?  It is, but is it just a coincidence?  If we know it has to be true, we should be able to further optimize with this knowledge.

In any case, I'm going to have another look at this.  I'm also going to study Charlie's recursive solution.  I didn't think of a way to use recursion last night--but it was getting pretty late and I was pretty tired.

With regard to the "Option Strict" clause, yes--I've found that using it almost always improves perfomance--it's a good habit to always use it.  Retrofitting existing code to use it isn't always easy though.

Thanks for your feedback.  This is fun!


  Posted by Ken Haley on 2005-09-24 21:15:23
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information