Expand my Community achievements bar.

SOLVED

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

Avatar

Level 4

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

Lawson02_1-1718660837094.png

Output:

Lawson02_2-1718660852258.png

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

(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

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

(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

Avatar

Level 4

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

Avatar

Community Advisor

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

Avatar

Level 4

Disregard my last post, I got your solution working with some tweaking. Thank you so much, you're such a big help! I wasn't very familiar with the get variable module, I had no idea that it would be able to store states between bundles!

 

Lawson02_1-1718732530875.png

Lawson02_2-1718732544244.png

 

Lawson02_0-1718732517915.png