moritz is right, brute forcing this is straightforward, unless we've completely misunderstood the challenge. Here's my code which, with the data you gave, finds the split to be groups 0, 1, 4, 6 and 2, 3, 5, 7. (Machine numbers starting with zero).
use strict; use warnings; my @costs; push @costs, [split(/\s+/)] for (<DATA>); my @combos; gen_set([0..7],[],4,\@combos); my $min_cost = 999999; my $min_set_num; for (0..$#combos) { my $set_cost = get_cost(@{$combos[$_]}); if ($set_cost < $min_cost) { $min_cost = $set_cost; $min_set_num = $_; } } print "Set number $min_set_num, cost $min_cost: ". join(q{ },@{$combos[$min_set_num]}) . "\n"; sub get_cost { my @list = @_; my %list = map { $_ => 1 } @list; my $cost; for my $li (@list) { for my $oi (grep {not exists $list{$_}} (0..7)) { $cost += $costs[$li]->[$oi]; } } return $cost; } sub gen_set { my ($from, $to, $num, $results) = @_; for my $item (@$from) { my @new_to = @$to; push @new_to, $item; if ($num == 1) { push @$results, \@new_to; } else { my @new_from = grep { $_ != $item } @$from; gen_set(\@new_from,\@new_to,$num-1,$results); } } } __DATA__ - 38 72 79 58 88 59 33 38 - 70 71 27 47 77 14 72 70 - 90 42 63 56 90 79 71 90 - 60 57 21 95 58 27 42 60 - 28 33 52 88 47 63 57 28 - 11 85 59 77 56 21 33 11 - 59 33 14 90 95 52 85 59 -

In reply to Re: "Divide" challenge by bellaire
in thread "Divide" challenge by grizzley

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.