Look at the problem from this way:
N is a number, for example it's 4.
K would be an array of digits, like:
[0, 1, 2, 3]
X is again, a number, let's say it's 11.
How do I count the amount of numbers matching these circumstances?
How I am currently doing this is:
- Create an array (I will call it
allnumbers) of all numbers between the smallest possible number made with the specified digits from K (
== 1001) AND the biggest possible number created using the highest digit from K, repeated as many times as the amount of N (
== 3333) that are divisible by X.
- Eliminate/remove all numbers from the
allnumbersarray that contain different digits from the ones specified under K
- Return the length of
allnumbersas the amount
I believe the final answer is