Sum of list numbers smaller than one goal












4












$begingroup$


I have five values ​​that I would like to add them so that they can be equal to or less than 3000.



v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
Subsets [{v1, v2, v3, v4, v5}]


For example:



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1


-> 2940



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2


-> 2940



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v3


-> 2940



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v4


-> 2940



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v5


-> 2940



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2


-> 2940



v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2 + v2


-> 2940



All are possibilities, among other possibilities.



Is there a feature that validates these possibilities?










share|improve this question











$endgroup$

















    4












    $begingroup$


    I have five values ​​that I would like to add them so that they can be equal to or less than 3000.



    v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
    Subsets [{v1, v2, v3, v4, v5}]


    For example:



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1


    -> 2940



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2


    -> 2940



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v3


    -> 2940



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v4


    -> 2940



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v5


    -> 2940



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2


    -> 2940



    v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2 + v2


    -> 2940



    All are possibilities, among other possibilities.



    Is there a feature that validates these possibilities?










    share|improve this question











    $endgroup$















      4












      4








      4





      $begingroup$


      I have five values ​​that I would like to add them so that they can be equal to or less than 3000.



      v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
      Subsets [{v1, v2, v3, v4, v5}]


      For example:



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v3


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v4


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v5


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2 + v2


      -> 2940



      All are possibilities, among other possibilities.



      Is there a feature that validates these possibilities?










      share|improve this question











      $endgroup$




      I have five values ​​that I would like to add them so that they can be equal to or less than 3000.



      v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
      Subsets [{v1, v2, v3, v4, v5}]


      For example:



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v3


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v4


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v5


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2


      -> 2940



      v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v1 + v2 + v2 + v2


      -> 2940



      All are possibilities, among other possibilities.



      Is there a feature that validates these possibilities?







      combinatorics






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago







      LCarvalho

















      asked 3 hours ago









      LCarvalhoLCarvalho

      5,65242886




      5,65242886






















          4 Answers
          4






          active

          oldest

          votes


















          4












          $begingroup$

          a = {140, 280, 420, 560, 700};
          results = Join @@ DeleteCases[
          IntegerPartitions[#, {1, ∞}, a] & /@ Range[3000],
          {}
          ];
          And @@ Thread[Total /@ results <= 3000]
          resulttable = Map[Lookup[Counts[#], a, 0] &, results];
          resulttable // Short



          True



          {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, <<1341>> , {19, 1, 0, 0, 0}, {21, 0, 0, 0, 0}}







          share|improve this answer











          $endgroup$





















            4












            $begingroup$

            Append 1 to the list of vs and use FrobeniusSolve:



            w = {v1, v2, v3, v4, v5, 1};
            res = Rest[FrobeniusSolve[w, 3000]][[All, ;; 5]];
            Length[res]



            1345




            Short @ res



            {{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1336>>,{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




            And @@ Thread[Total /@ res <= 3000]



            True




            Up to ordering, res is the same as Henrik's resulttable:



            Sort[res] == Sort[resulttable]



            True




            An alternative way to use IntegerPartitions using w:



            res2 = DeleteCases[Rest@IntegerPartitions[3000, All, w], 1, 2];
            Length@res2



            1345




            restab = Map[Lookup[Counts[#], Most @ w, 0] &] @ res2;
            Sort[res] == Sort[restab]



            True




            To get the totals that can be obtained using vs:



            Sort[DeleteDuplicates[res.Most[w]]] (* or *)
            Sort[3000 - DeleteDuplicates@Rest[FrobeniusSolve[w, 3000]][[All, -1]]]



            {140, 280, 420, 560, 700, 840, 980, 1120, 1260, 1400, 1540, 1680,
            1820, 1960, 2100, 2240, 2380, 2520, 2660, 2800, 2940}




            Sort @ Counts[res.Most[w]]



            <|140 -> 1, 280 -> 2, 420 -> 3, 560 -> 5, 700 -> 7, 840 -> 10,
            980 -> 13, 1120 -> 18, 1260 -> 23, 1400 -> 30, 1540 -> 37,
            1680 -> 47, 1820 -> 57, 1960 -> 70, 2100 -> 84, 2240 -> 101,
            2380 -> 119, 2520 -> 141, 2660 -> 164, 2800 -> 192, 2940 -> 221|>







            share|improve this answer











            $endgroup$





















              3












              $begingroup$

              v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
              Select[Subsets[{v1, v2, v3, v4, v5}], Total[#] <= goal &]


              Are you sure your "goal" is 3000? Every subset totals less than that.



              And what does 21 * v1 in your question refer to? What is $21$, and why multiplication?






              share|improve this answer









              $endgroup$





















                2












                $begingroup$

                a = {140, 280, 420, 560, 700};
                coef = Tuples[Range[0, 21], 5];
                vec = coef.a;

                Extract[coef, Position[Ramp[vec - 3000], 0]] // Short



                {{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1335>>,{18,1,0,0,0},{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                Pick[vec, Ramp[vec - 3000], 0] // Short



                {0,700,1400,2100,2800,560,1260,1960,2660,1120,1820,2520,1680,2380,<<1318>>,2940,2800,2380,2940,2800,2660,2940,2520,2940,2800,2660,2940,2800,2940}







                share|improve this answer









                $endgroup$













                  Your Answer





                  StackExchange.ifUsing("editor", function () {
                  return StackExchange.using("mathjaxEditing", function () {
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
                  });
                  });
                  }, "mathjax-editing");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "387"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: false,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189957%2fsum-of-list-numbers-smaller-than-one-goal%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  4












                  $begingroup$

                  a = {140, 280, 420, 560, 700};
                  results = Join @@ DeleteCases[
                  IntegerPartitions[#, {1, ∞}, a] & /@ Range[3000],
                  {}
                  ];
                  And @@ Thread[Total /@ results <= 3000]
                  resulttable = Map[Lookup[Counts[#], a, 0] &, results];
                  resulttable // Short



                  True



                  {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, <<1341>> , {19, 1, 0, 0, 0}, {21, 0, 0, 0, 0}}







                  share|improve this answer











                  $endgroup$


















                    4












                    $begingroup$

                    a = {140, 280, 420, 560, 700};
                    results = Join @@ DeleteCases[
                    IntegerPartitions[#, {1, ∞}, a] & /@ Range[3000],
                    {}
                    ];
                    And @@ Thread[Total /@ results <= 3000]
                    resulttable = Map[Lookup[Counts[#], a, 0] &, results];
                    resulttable // Short



                    True



                    {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, <<1341>> , {19, 1, 0, 0, 0}, {21, 0, 0, 0, 0}}







                    share|improve this answer











                    $endgroup$
















                      4












                      4








                      4





                      $begingroup$

                      a = {140, 280, 420, 560, 700};
                      results = Join @@ DeleteCases[
                      IntegerPartitions[#, {1, ∞}, a] & /@ Range[3000],
                      {}
                      ];
                      And @@ Thread[Total /@ results <= 3000]
                      resulttable = Map[Lookup[Counts[#], a, 0] &, results];
                      resulttable // Short



                      True



                      {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, <<1341>> , {19, 1, 0, 0, 0}, {21, 0, 0, 0, 0}}







                      share|improve this answer











                      $endgroup$



                      a = {140, 280, 420, 560, 700};
                      results = Join @@ DeleteCases[
                      IntegerPartitions[#, {1, ∞}, a] & /@ Range[3000],
                      {}
                      ];
                      And @@ Thread[Total /@ results <= 3000]
                      resulttable = Map[Lookup[Counts[#], a, 0] &, results];
                      resulttable // Short



                      True



                      {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, <<1341>> , {19, 1, 0, 0, 0}, {21, 0, 0, 0, 0}}








                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 2 hours ago

























                      answered 3 hours ago









                      Henrik SchumacherHenrik Schumacher

                      51k469145




                      51k469145























                          4












                          $begingroup$

                          Append 1 to the list of vs and use FrobeniusSolve:



                          w = {v1, v2, v3, v4, v5, 1};
                          res = Rest[FrobeniusSolve[w, 3000]][[All, ;; 5]];
                          Length[res]



                          1345




                          Short @ res



                          {{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1336>>,{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                          And @@ Thread[Total /@ res <= 3000]



                          True




                          Up to ordering, res is the same as Henrik's resulttable:



                          Sort[res] == Sort[resulttable]



                          True




                          An alternative way to use IntegerPartitions using w:



                          res2 = DeleteCases[Rest@IntegerPartitions[3000, All, w], 1, 2];
                          Length@res2



                          1345




                          restab = Map[Lookup[Counts[#], Most @ w, 0] &] @ res2;
                          Sort[res] == Sort[restab]



                          True




                          To get the totals that can be obtained using vs:



                          Sort[DeleteDuplicates[res.Most[w]]] (* or *)
                          Sort[3000 - DeleteDuplicates@Rest[FrobeniusSolve[w, 3000]][[All, -1]]]



                          {140, 280, 420, 560, 700, 840, 980, 1120, 1260, 1400, 1540, 1680,
                          1820, 1960, 2100, 2240, 2380, 2520, 2660, 2800, 2940}




                          Sort @ Counts[res.Most[w]]



                          <|140 -> 1, 280 -> 2, 420 -> 3, 560 -> 5, 700 -> 7, 840 -> 10,
                          980 -> 13, 1120 -> 18, 1260 -> 23, 1400 -> 30, 1540 -> 37,
                          1680 -> 47, 1820 -> 57, 1960 -> 70, 2100 -> 84, 2240 -> 101,
                          2380 -> 119, 2520 -> 141, 2660 -> 164, 2800 -> 192, 2940 -> 221|>







                          share|improve this answer











                          $endgroup$


















                            4












                            $begingroup$

                            Append 1 to the list of vs and use FrobeniusSolve:



                            w = {v1, v2, v3, v4, v5, 1};
                            res = Rest[FrobeniusSolve[w, 3000]][[All, ;; 5]];
                            Length[res]



                            1345




                            Short @ res



                            {{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1336>>,{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                            And @@ Thread[Total /@ res <= 3000]



                            True




                            Up to ordering, res is the same as Henrik's resulttable:



                            Sort[res] == Sort[resulttable]



                            True




                            An alternative way to use IntegerPartitions using w:



                            res2 = DeleteCases[Rest@IntegerPartitions[3000, All, w], 1, 2];
                            Length@res2



                            1345




                            restab = Map[Lookup[Counts[#], Most @ w, 0] &] @ res2;
                            Sort[res] == Sort[restab]



                            True




                            To get the totals that can be obtained using vs:



                            Sort[DeleteDuplicates[res.Most[w]]] (* or *)
                            Sort[3000 - DeleteDuplicates@Rest[FrobeniusSolve[w, 3000]][[All, -1]]]



                            {140, 280, 420, 560, 700, 840, 980, 1120, 1260, 1400, 1540, 1680,
                            1820, 1960, 2100, 2240, 2380, 2520, 2660, 2800, 2940}




                            Sort @ Counts[res.Most[w]]



                            <|140 -> 1, 280 -> 2, 420 -> 3, 560 -> 5, 700 -> 7, 840 -> 10,
                            980 -> 13, 1120 -> 18, 1260 -> 23, 1400 -> 30, 1540 -> 37,
                            1680 -> 47, 1820 -> 57, 1960 -> 70, 2100 -> 84, 2240 -> 101,
                            2380 -> 119, 2520 -> 141, 2660 -> 164, 2800 -> 192, 2940 -> 221|>







                            share|improve this answer











                            $endgroup$
















                              4












                              4








                              4





                              $begingroup$

                              Append 1 to the list of vs and use FrobeniusSolve:



                              w = {v1, v2, v3, v4, v5, 1};
                              res = Rest[FrobeniusSolve[w, 3000]][[All, ;; 5]];
                              Length[res]



                              1345




                              Short @ res



                              {{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1336>>,{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                              And @@ Thread[Total /@ res <= 3000]



                              True




                              Up to ordering, res is the same as Henrik's resulttable:



                              Sort[res] == Sort[resulttable]



                              True




                              An alternative way to use IntegerPartitions using w:



                              res2 = DeleteCases[Rest@IntegerPartitions[3000, All, w], 1, 2];
                              Length@res2



                              1345




                              restab = Map[Lookup[Counts[#], Most @ w, 0] &] @ res2;
                              Sort[res] == Sort[restab]



                              True




                              To get the totals that can be obtained using vs:



                              Sort[DeleteDuplicates[res.Most[w]]] (* or *)
                              Sort[3000 - DeleteDuplicates@Rest[FrobeniusSolve[w, 3000]][[All, -1]]]



                              {140, 280, 420, 560, 700, 840, 980, 1120, 1260, 1400, 1540, 1680,
                              1820, 1960, 2100, 2240, 2380, 2520, 2660, 2800, 2940}




                              Sort @ Counts[res.Most[w]]



                              <|140 -> 1, 280 -> 2, 420 -> 3, 560 -> 5, 700 -> 7, 840 -> 10,
                              980 -> 13, 1120 -> 18, 1260 -> 23, 1400 -> 30, 1540 -> 37,
                              1680 -> 47, 1820 -> 57, 1960 -> 70, 2100 -> 84, 2240 -> 101,
                              2380 -> 119, 2520 -> 141, 2660 -> 164, 2800 -> 192, 2940 -> 221|>







                              share|improve this answer











                              $endgroup$



                              Append 1 to the list of vs and use FrobeniusSolve:



                              w = {v1, v2, v3, v4, v5, 1};
                              res = Rest[FrobeniusSolve[w, 3000]][[All, ;; 5]];
                              Length[res]



                              1345




                              Short @ res



                              {{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1336>>,{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                              And @@ Thread[Total /@ res <= 3000]



                              True




                              Up to ordering, res is the same as Henrik's resulttable:



                              Sort[res] == Sort[resulttable]



                              True




                              An alternative way to use IntegerPartitions using w:



                              res2 = DeleteCases[Rest@IntegerPartitions[3000, All, w], 1, 2];
                              Length@res2



                              1345




                              restab = Map[Lookup[Counts[#], Most @ w, 0] &] @ res2;
                              Sort[res] == Sort[restab]



                              True




                              To get the totals that can be obtained using vs:



                              Sort[DeleteDuplicates[res.Most[w]]] (* or *)
                              Sort[3000 - DeleteDuplicates@Rest[FrobeniusSolve[w, 3000]][[All, -1]]]



                              {140, 280, 420, 560, 700, 840, 980, 1120, 1260, 1400, 1540, 1680,
                              1820, 1960, 2100, 2240, 2380, 2520, 2660, 2800, 2940}




                              Sort @ Counts[res.Most[w]]



                              <|140 -> 1, 280 -> 2, 420 -> 3, 560 -> 5, 700 -> 7, 840 -> 10,
                              980 -> 13, 1120 -> 18, 1260 -> 23, 1400 -> 30, 1540 -> 37,
                              1680 -> 47, 1820 -> 57, 1960 -> 70, 2100 -> 84, 2240 -> 101,
                              2380 -> 119, 2520 -> 141, 2660 -> 164, 2800 -> 192, 2940 -> 221|>








                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 1 hour ago

























                              answered 2 hours ago









                              kglrkglr

                              180k9199410




                              180k9199410























                                  3












                                  $begingroup$

                                  v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
                                  Select[Subsets[{v1, v2, v3, v4, v5}], Total[#] <= goal &]


                                  Are you sure your "goal" is 3000? Every subset totals less than that.



                                  And what does 21 * v1 in your question refer to? What is $21$, and why multiplication?






                                  share|improve this answer









                                  $endgroup$


















                                    3












                                    $begingroup$

                                    v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
                                    Select[Subsets[{v1, v2, v3, v4, v5}], Total[#] <= goal &]


                                    Are you sure your "goal" is 3000? Every subset totals less than that.



                                    And what does 21 * v1 in your question refer to? What is $21$, and why multiplication?






                                    share|improve this answer









                                    $endgroup$
















                                      3












                                      3








                                      3





                                      $begingroup$

                                      v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
                                      Select[Subsets[{v1, v2, v3, v4, v5}], Total[#] <= goal &]


                                      Are you sure your "goal" is 3000? Every subset totals less than that.



                                      And what does 21 * v1 in your question refer to? What is $21$, and why multiplication?






                                      share|improve this answer









                                      $endgroup$



                                      v1 = 140; v2 = 280; v3 = 420; v4 = 560; v5 = 700; goal = 3000;
                                      Select[Subsets[{v1, v2, v3, v4, v5}], Total[#] <= goal &]


                                      Are you sure your "goal" is 3000? Every subset totals less than that.



                                      And what does 21 * v1 in your question refer to? What is $21$, and why multiplication?







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 3 hours ago









                                      David G. StorkDavid G. Stork

                                      24.1k22153




                                      24.1k22153























                                          2












                                          $begingroup$

                                          a = {140, 280, 420, 560, 700};
                                          coef = Tuples[Range[0, 21], 5];
                                          vec = coef.a;

                                          Extract[coef, Position[Ramp[vec - 3000], 0]] // Short



                                          {{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1335>>,{18,1,0,0,0},{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                                          Pick[vec, Ramp[vec - 3000], 0] // Short



                                          {0,700,1400,2100,2800,560,1260,1960,2660,1120,1820,2520,1680,2380,<<1318>>,2940,2800,2380,2940,2800,2660,2940,2520,2940,2800,2660,2940,2800,2940}







                                          share|improve this answer









                                          $endgroup$


















                                            2












                                            $begingroup$

                                            a = {140, 280, 420, 560, 700};
                                            coef = Tuples[Range[0, 21], 5];
                                            vec = coef.a;

                                            Extract[coef, Position[Ramp[vec - 3000], 0]] // Short



                                            {{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1335>>,{18,1,0,0,0},{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                                            Pick[vec, Ramp[vec - 3000], 0] // Short



                                            {0,700,1400,2100,2800,560,1260,1960,2660,1120,1820,2520,1680,2380,<<1318>>,2940,2800,2380,2940,2800,2660,2940,2520,2940,2800,2660,2940,2800,2940}







                                            share|improve this answer









                                            $endgroup$
















                                              2












                                              2








                                              2





                                              $begingroup$

                                              a = {140, 280, 420, 560, 700};
                                              coef = Tuples[Range[0, 21], 5];
                                              vec = coef.a;

                                              Extract[coef, Position[Ramp[vec - 3000], 0]] // Short



                                              {{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1335>>,{18,1,0,0,0},{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                                              Pick[vec, Ramp[vec - 3000], 0] // Short



                                              {0,700,1400,2100,2800,560,1260,1960,2660,1120,1820,2520,1680,2380,<<1318>>,2940,2800,2380,2940,2800,2660,2940,2520,2940,2800,2660,2940,2800,2940}







                                              share|improve this answer









                                              $endgroup$



                                              a = {140, 280, 420, 560, 700};
                                              coef = Tuples[Range[0, 21], 5];
                                              vec = coef.a;

                                              Extract[coef, Position[Ramp[vec - 3000], 0]] // Short



                                              {{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,2},{0,0,0,0,3},{0,0,0,0,4},{0,0,0,1,0},<<1335>>,{18,1,0,0,0},{19,0,0,0,0},{19,1,0,0,0},{20,0,0,0,0},{21,0,0,0,0}}




                                              Pick[vec, Ramp[vec - 3000], 0] // Short



                                              {0,700,1400,2100,2800,560,1260,1960,2660,1120,1820,2520,1680,2380,<<1318>>,2940,2800,2380,2940,2800,2660,2940,2520,2940,2800,2660,2940,2800,2940}








                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered 2 hours ago









                                              Okkes DulgerciOkkes Dulgerci

                                              4,4851817




                                              4,4851817






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Mathematica Stack Exchange!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  Use MathJax to format equations. MathJax reference.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189957%2fsum-of-list-numbers-smaller-than-one-goal%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  SQL Server 17 - Attemping to backup to remote NAS but Access is denied

                                                  Always On Availability groups resolving state after failover - Remote harden of transaction...

                                                  Restoring from pg_dump with foreign key constraints