in reply to Re^4: Divide array of integers into most similar value halves
in thread Divide array of integers into most similar value halves

Did you try my algorithm at Re^2: NP-complete sometimes isn't (A benchmark)? It is guaranteed to always find the best possible answer. It has no bug with repeated numbers. It is not the fastest option, but it may well be fast enough for your purposes.
  • Comment on Re^5: Divide array of integers into most similar value halves

Replies are listed 'Best First'.
Re^6: Divide array of integers into most similar value halves
by Pepe (Sexton) on Sep 04, 2008 at 18:44 UTC
    Hey tilly,

    I haven't tried that one. In fact I hadn't even notice there was another node with that theme! I looked for hours before my first post, but I guess the name of the node didn't appeal to me, since I did not even know about teh existence of NP-complete problems.
    It's pretty long and seems slow but it may be the answer to my prays. I hope it doesn't take days...
    I'll try it.
    Thanks.
    Pepe.
      I wrote that thread after yours because I thought it of independent interest for people who weren't following your problem. I posted a pointer to that thread from yours, but I guess you missed the pointer.

      Please do get back to me and tell me whether that solution was fast enough for you.

        Oh! I see...
        Sorry for missing the post, I woulded try before.
        I just tried now and it does awesome in terms of getting it right every single time. It takes a while in the most difficult cases, but it's pretty fast overall and I think I can live with it being slow only sometimes.
        The problem came when it found this:

        @array = (8,45.5,42.5,68,42,31.5,19);

        If it's too much of a problem I think I could round up all the decimals before passing it to the array.

        Thanks a lot for trying.
        Pepe.