Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

Here's the algorithm:
use constant COL => 4; my @data = qw( 10 15 25 30 10 13 ); my @cols = map [$_], @data; while (@data > COL) { my $i = 0; my $s = $data[$i] + $data[$i+1]; for my $j (1 .. @data-2) { ($i, $s) = ($j, $data[$j] + $data[$j+1]) if $data[$j] + $data[$j+1] < $s; } splice @data, $i, 2, $s; splice @cols, $i, 2, [@{ $cols[$i] }, @{ $cols[$i+1] }]; }


In reply to Re: Puzzle: need a more general algorithm by japhy
in thread Puzzle: need a more general algorithm by Ovid

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (8)
    As of 2014-12-29 13:11 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (187 votes), past polls