| 10-29-2006, 07:19 PM | #1 |
Rules
#3 - Multiples You simply need to make a function: function TotalMultiples takes string digits, integer d returns integer digits: an string with 1 to 7 characters : "0" , "1", "2", "3", "4", "5", "6", "7", "8", "9" (only digits) d: an integer number ( 1<=d<=50 ) You just have to return the number of possible permutations of digits that are multiples of d. TotalMultiples("12345", 1) : 120 TotalMultiples("000" , 5) : 1 TotalMultiples("1234511",1) : 840 TotalMultiples("234", 6) : 4 TotalMultiples("1234321", 50) : 0 TotalMultiples("1234501", 50) : 60 TotalMultiples("4949" , 49 ) : 1 |
| 10-30-2006, 03:28 PM | #2 |
fixed bugs and added some big testcases |
| 10-30-2006, 11:00 PM | #3 |
How do you keep coming up with these problems :) |
| 10-31-2006, 12:48 AM | #4 |
"TotalMultiples("4949" , 49 ) : 1" Is wrong. 49 and 4949 are both divisible by 49. That's 2 that it's divisible by already. |
| 10-31-2006, 01:54 AM | #5 |
but you can't form 49, it must have all the digits , that's what a permutation is |
| 10-31-2006, 01:57 AM | #6 |
Oh, oops. You're right. =P |
| 10-31-2006, 08:04 AM | #7 |
My god, I actually understand what your talking about her. Should have an entry fairly quickly. |
| 10-31-2006, 10:09 AM | #8 |
Considering the maximum number of permutations is fairly low, I'm wondering if designing an efficient brute force algorithm isn't the best way to go here. |
| 10-31-2006, 11:08 AM | #9 |
this is actually very simple, but require a bit big loop. Unless one can find a formula for it :P |
| 10-31-2006, 11:36 AM | #10 |
Hm... my guess would be that Vexorian is getting tired of having to deal with more than two submissions... Well, there's still some time left. And, I don't think the deadline will be shortened this time ![]() |
| 10-31-2006, 12:41 PM | #11 | |
Quote:
|
| 10-31-2006, 03:46 PM | #12 | |
Quote:
Millions of possible inputs. |
| 10-31-2006, 03:52 PM | #13 |
What? Number of inputs is irrelevant. That maximum number of permutations of a 7 digit string is 7!, or 5040 (I think, that's by mental arithematic). |
| 10-31-2006, 04:29 PM | #14 |
Yes, and you can have over a million inputs of strings. |
| 10-31-2006, 04:33 PM | #15 |
That's totally irrelevant? For any given input you have a maximum of 5040 numbers to check. How many different inputs you can receive has nothing to do with the speed of the algorithm. |
