Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: nested combinations: algorithm advice?

by revdiablo (Prior)
on Sep 22, 2004 at 16:44 UTC ( #392970=note: print w/replies, xml ) Need Help??

in reply to Re: nested combinations: algorithm advice?
in thread nested combinations: algorithm advice?

Thanks for the reply, and good guess! I've updated my original post to explain a bit more about what I'm trying to do.

I like your idea, but note one thing about your solution -- it compares lines to eachother twice. When it's on line 1, it compares to line 2, and when it's on line 2, it compares to line 1 (even though it already has). That's why tye's combinations sub is really nice, it cleanly eliminates that problem. I'm not sure if using combinations is faster or slower (intuition tells me it would be faster, since it's comparing less, but perhaps there's some overhead getting in the way), but the duplication was driving me crazy.

Replies are listed 'Best First'.
Re^3: nested combinations: algorithm advice?
by Jasper (Chaplain) on Sep 22, 2004 at 16:54 UTC
    Yes, I tried doing the seen sort join thing before the matches thereby avoiding the 2 - 1, 1 - 2 overhead, but with the data given, there was no benefit (in fact it was slower).

    I did benchmark your code against mine, and on the DATA, mine was about 40% faster. Possibly on a much more extensive set of data, the difference wouldn't be so great.
      with the data given, there was no benefit

      The given data was only a sample. [Yes, I probably should have said this. In retrospect, there are quite a few things I could have done better with my original question.] The actual data has several thousand lines. Yours may still be faster, but then there would be the additional step of eliminating the duplicate combinations.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://392970]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2019-11-18 22:24 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (92 votes). Check out past polls.