How can I determine the total possible distributions of a sequence if order matters, but repeated numbers don't?

22 Views Asked by At

I have 5 different digits, 0 to 4, being distributed into 64 spaces.
I'm starting with:

0123401234012340123401234012340123401234012340123401234012340123

edit I failed to mention that I'm starting with the seed number above and rearranging them on digit at a time using Heap's algorithm. I have to use the numbers above and not just any set of numbers. So all 0s is out.

Order does matter, but only distinct distributions are counted. So, if we were working with only 6 digits: 012340 is the same as 012340 (When technically the two 0s were swapped.) so we would discard the second number there.

How can I determine how many distinct arrangements there are? I have a C# application crunching the numbers for me and so far it's found 64,000 distinct number arrangements (After 24 hours). I'm trying to figure out if I'm close to being done, or if it's barely gotten started.

When I ran the code on only 6 digits, it found 360 distinct numbers out of 720 possible arrangements. 8 digits found 5040 distinct out of 40320 possible arrangements. Clearly there's a formula here, but I'm unable to see it.