Page 1 of 1

Problem 043

Posted: Mon Jan 26, 2009 5:03 am
by helstreak
can the divisible numbers start with d1...something like:

d1d2d3 = someNumber is divisible by 2
d2d3d4 = someNumber is divisible by 3
d3d4d5 = ...

thanks for your help

Re: Problem 43

Posted: Mon Jan 26, 2009 6:56 am
by DNS
May be it possible, but for this problem numbers start with 2nd digit.

Problem 043

Posted: Thu Feb 25, 2010 1:25 am
by ccarr
I just recently started learning C# as my first programming language and solved this problem using what I think is an efficient algorithm (156 ms). Could I PM or email my code to someone for a critique?

Re: Problem 043

Posted: Thu Feb 25, 2010 4:17 am
by rayfil
I think is an efficient algorithm (156 ms)
Efficiency is a very relative notion.

You do admit yourself that you are a beginner. Imagine someone taking up art painting classes and completing their first canvas within a month. And then watching someone on TV complete a beautiful scenery within 30 minutes. That should not discourage the pupil from trying to improve; some day he could perform as well with continued effort.

I have no knowledge of C# but my algo runs in 0.02 ms (almost 10,000 times faster than yours). Trying to optimize your algo may not gain you much. Based on what you may have learned while developing your current algo, you may be able to devise a modified algo (or a completely different one) which should be much more efficient and run 10-100 times faster. That can be the fun part of programming.

Re: Problem 043

Posted: Thu Feb 25, 2010 12:50 pm
by ccarr
Thanks for your response, rayfil; I understand exactly what you mean. I know I have a long way to go before I know even half the ins-and-outs of good programming, but there's no substitute for the guidance of an experienced practitioner along the way. While it'll no doubt be a very long time before I can paint a landscape in 30 minutes, it won't hurt to know which brushes to bring to the easel! I guess what I meant by "efficient" was just that I didn't have any superfluous steps according to the particular approach I took, even if that approach isn't necessarily the fastest. Out of curiosity, what language(s) do you use?

Re: Problem 043

Posted: Thu Feb 25, 2010 3:49 pm
by quilan
He's our token assembly programmer ;-).

Re: Problem 043

Posted: Sat Feb 27, 2010 5:29 am
by rayfil
As quilan mentioned, I do use assembly. However, in this context, other good compiled languages (with a decent compiler) using an algo similar to what I used should be able to provide an answer in 0.1 ms or less on a relatively recent computer (mine is a 2-year old 1.86GHz CoreDuo).

Re: Problem 043

Posted: Sun Apr 24, 2011 9:19 pm
by AArmada
How many numbers are there that satisfy the conditions? Im getting 24, but my sum is wrong.

Re: Problem 043

Posted: Sun Apr 24, 2011 9:45 pm
by jaap
AArmada wrote:How many numbers are there that satisfy the conditions? Im getting 24, but my sum is wrong.
There are much fewer than that so many of your numbers cannot satisfy all the conditions.

Re: Problem 043

Posted: Sun Apr 24, 2011 9:59 pm
by AArmada
jaap wrote:There are much fewer than that so many of your numbers cannot satisfy all the conditions.
Solved it, thanks for your help.

Re: Problem 043

Posted: Mon Jul 18, 2011 11:53 pm
by smjg
Just to clarify, am I right in making out that
  • the property to be tested is exactly d2d3d4 divisible by 2, d3d4d5 divisible by 3, etc. as opposed to any other permutation?
  • pandigital numbers in which the 0 occurs at the beginning (109 digit) still count?

Re: Problem 043

Posted: Tue Jul 19, 2011 4:38 am
by rayfil
•the property to be tested is exactly d2d3d4 divisible by 2, d3d4d5 divisible by 3, etc. as opposed to any other permutation?
Yes
•pandigital numbers in which the 0 occurs at the beginning (109 digit) still count?
No