Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Divide an array into 2 subsets to verify their sum is equal or not.

by BrowserUk (Pope)
on May 02, 2013 at 11:10 UTC ( #1031732=note: print w/ replies, xml ) Need Help??


in reply to Re: Divide an array into 2 subsets to verify their sum is equal or not.
in thread Divide an array into 2 subsets to verify their sum is equal or not.

A couple of questions:

  1. Why pass in a reference if the first thing you are going to do is copy the reference array to a local array?
    sub check_arrays { my @full_array = @{shift()};
  2. Why make a local copy of the array at all, when all the uses (join, sum, sort) of it require you to pass a list?

    Ie. Why not my $sum = sum @$ref; etc.

  3. Isn't re-summing your partial array over and over wildly inefficient?

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.


Comment on Re^2: Divide an array into 2 subsets to verify their sum is equal or not.
Select or Download Code
Re^3: Divide an array into 2 subsets to verify their sum is equal or not.
by kcott (Abbot) on May 02, 2013 at 21:19 UTC

    ++ Thanks. All your points are perfectly valid. There were other issues as well. I've substantially rewritten the solution.

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031732]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-12-19 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (78 votes), past polls