Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Find combination of numbers whose sum equals X

by tybalt89 (Prior)
on Nov 20, 2020 at 12:44 UTC ( #11123894=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
      $target > 0 && $from =~ s/\d+// or return ();
      uniq find( $target - $&, $from, "$have+$&"), find(  $target, $from, 
    +$have );
      }
    
  2. or download this
    1+99
    2+40+50+3+5
    ...
    5+5+5+5+80
    5+5+10+80
    5+15+80
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2021-01-23 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?