http://www.perlmonks.org?node_id=392907


in reply to nested combinations: algorithm advice?

2 nested loops is bad, much less 4. I assure you that rethinking the problem with the proper data structure will make the iterative complexity much less. Since it looks like you are doing something with permuations, check out How do I permute N elements of a list?

Provide a description of your problem, and like the monks above said, we may be able to help a bit more...
  • Comment on Re: nested combinations: algorithm advice?

Replies are listed 'Best First'.
Re^2: nested combinations: algorithm advice?
by revdiablo (Prior) on Sep 22, 2004 at 17:39 UTC

    Forward: I hope this reply isn't taken the wrong way. I'm not trying to flame, just trying to further explain things. I tried to be as civil as possible, and if I've failed, I'm sure I'll know it by all the downvotes. 8^)

    I assure you that rethinking the problem with the proper data structure will make the iterative complexity much less.

    Rethinking the problem is why I posted a question in the first place. I needed a fresh perspective on things. If you have any ideas about what data structure would help, I'm all ears.

    Since it looks like you are doing something with permuations

    Actually, I'm working with combinations. And only the 2-element combinations, at that. For all I know, there may be another more appropriate term to describe these things. From my understanding, though, "permutations" is not it. Update: there's a nice description of the difference at Iterating over combinations.

    Provide a description of your problem, and like the monks above said, we may be able to help a bit more

    I apologize for this. I posted the original question in haste, and apparently forgot to mention a few important things.