Adding a number from a bundle until it is equal to a number | Community
Skip to main content
Lawson02
Level 6
June 17, 2024
Solved

Adding a number from a bundle until it is equal to a number

  • June 17, 2024
  • 1 reply
  • 993 views

I need to add a number from a bundle until it gets to a certain point then stop. Say I have 4 bundles with 1,2,4,8 and I need to make the number equal to 7. How would I add each bundle one by one and move on to the next step when the combined value equals 7, aka only the first 3 bundles pass through while the last gets discarded

 

1st bundle

1 !>= 7

2nd bundle

1+2 !>= 7

3rd bundle

1+2+4 >= 7

Since equal or greater stop accepting bundles and move to next step

 

Here is a coding example

Output:

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ChrisStephens

(Reposting here, as it's a more applicable forum)

 

While I have about a million questions about this, I'll refrain myself.

 

Assuming that your fusion is structured like your code snippet...

1. Iterate thru your bundles

2. Have a get variable module, variable = {testValue}

3. Have a  filter for {testValue} <= 7

4. Do whatever needs doing

5. Have a set variable module, variable = {testValue}, value = {testValue from 2} + {value from iterator}

6. Aggregator linked to your iterator

1 reply

ChrisStephens
Community Advisor
ChrisStephensCommunity AdvisorAccepted solution
Community Advisor
June 18, 2024

(Reposting here, as it's a more applicable forum)

 

While I have about a million questions about this, I'll refrain myself.

 

Assuming that your fusion is structured like your code snippet...

1. Iterate thru your bundles

2. Have a get variable module, variable = {testValue}

3. Have a  filter for {testValue} <= 7

4. Do whatever needs doing

5. Have a set variable module, variable = {testValue}, value = {testValue from 2} + {value from iterator}

6. Aggregator linked to your iterator

Lawson02
Lawson02Author
Level 6
June 18, 2024

I'm not so sure that I understand your implementation. What questions do you have? I basically need to find a combination of hours from an hours object that totals to a certain number. In the example I gave it was 1,2,3.  

 

Ex.

{testValue} = 0

Bundle 1

{testValue} 1 >= 7

Bundle 2

{testValue} 1+2 >= 7

Bundle 3

{testValue} 1+2+4 >= 7

Bundle 4

{testValue} 1+2+4+8 !>= 7

It doesn't matter to me that all of the bundles get executed I just need to know how to stop at bundle 3 in the execution

ChrisStephens
Community Advisor
Community Advisor
June 18, 2024

Right, the process that I put in (the numbered list) will do that.