in reply to Speeding permutation counting

albert,
I found this a neat an interesting problem but I haven't had a chance to try out my idea. I do have a couple of questions first:

I don't think any answer to the questions would invalidate my idea but it might change the implementation a bit. Since I do not have time to try it myself, I am laying it out here.

I believe you should be able to mathematically determine the counts without doing the comparisons. I believe all you need to do is count how many 0s and 1s there are for each position. To further speed up the process, I might even consider doing the counting using Inline::C.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Speeding permutation counting
by BrowserUk (Patriarch) on Jul 19, 2007 at 20:20 UTC
      BrowserUk,
      What I am suggesting is that if you know the number of 1s and 0s in all strings in position 1, you should be able to calculate the number of '11', '00', '10', and '01' at position 1 without comparing any of the strings. This would still have to be done for all strings at all positions - I am just trying to eliminate the comparisons.

      Cheers - L~R

        Oh. I see what you mean.

        Eg. If of 1000 strings, 500 have a 1 in bit 0, then you know that in the 500500 2-way compares, you would get '00' & '11' 1/4 of the time each and '01' or '10' 1/2 of the time.

        But I don't see a way of determining how many '10's relative to the '01's?

        And no way to determine which pairs of strings render which values for any given bit, nor a count of the four possible values for any given pair of strings?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.