brute forcing it should be in the realm of possibility. 186 Choose 6 = 53,011,617,022

Unfortunately, it's both less and more complicated than that.

(In the sample dataset), there are only 94 unique values; so 814,216,767 is very doable. It takes about 20 minutes in pure Perl to find the 142,138,770 complient groups of 6.

But then you have to come up with 31 of those sets of 6, where the 186 values, contained match the original 186.

Something like 814216767! / (814216767-31)! * 1 / 31!

Which I get to be something like: 2.07931e242. Somewhat too big to brute force.

Mind you, the OP only wanted one, not all of the solutions, so maybe it is still possible without heuristics. The trouble is, that he suggested that he wanted a different solution each time.

The problem with the heuristics offered so far, is that they are either determanistic and will find the same solution each time. Or non-determanistic and so might run for a very long time before finding one. Or worse. Some of them seemed to, more or less frequently, randomly choose starting positions from which their heuristics never find a solution.

I was working on an idea that encoded the complient 6of94 groups as bitstrings and saved each in 6 of 94 files according to the values contained. You then pick a file & mask at random; and use it to exclude files that contain values already in that mask--so if your first mask has the bit set for the 311 value, which can only appear once, you can immediately exclude all the masks in the 311 file. You then pick another file at random ANDing the masks with the original and rejecting collisions; Once you find a compatible mask, you OR it with the first; reject the files for any maxed out values ones, and repeat till you've selected 31 masks.

But the OP seemed to loose interest--or silently chose to go with one of the existing solutions--and I cracked a tooth.

Whilst waiting at the dentist, I was trying to distract myself by working out what the OPs purpose might be. And the best I could come up with was randomly (re)distributing variable size images or thumbnails onto a fixed width page (840-900 wide), on a grid 6 wide and 31 deep. That thought, the type of website such formatting is frequently done, the effort involved in coding the solution, and the toothache, meant I lost interest also.


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.
RIP an inspiration; A true Folk's Guy

In reply to Re^4: Bin packing problem variation repost (see[834245]) by BrowserUk
in thread Bin packing problem variation repost (see[834245]) by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.