Sum of combination without repetition

i want to get all possible sum combination of a int list without repetion whose sum is a given number. For example my list is {2,3,4} and the target is 7. I want the robot to this operations:
and not doing like 4+3 because it is a repetion. And return 3+4 that is equal to 7(the target).
I’m doing this because i want to test how much time it takes the robot to do this operation. In the real data i have like 15 numbers in the list. I know there is a similar question in here but the vba code posted it doesn’t work for me :frowning: .

I didnt get this kindly elaborate a bit more pls, that could help us go in right direction
Cheers @Mustafa_Hamed

@Palaniyappan ok thanks for the reply i’ll try to explain more. So i have this list {2,3,4} and i want the robot sum all the possible combination without repetion. So the robot will start with doing first element(2) plus second(3), first element plus third, second plus third, and finally first+second+third. I don’t want the robot to do like second+first because i’ve already done it before(first+second)(and it’s a waste of time) and so on… At the end, since the target is 7, i want the output to be second+third because it’s the only case that is equal to the target (7).

hello @Mustafa_Hamed

i have a small workflow which can give you all the combination without repeating but one case is sum of all values is not in that case.

give a try
Excel.xaml (8.9 KB)

Hi @Mustafa_Hamed,

Take a case, If these —> 2,3,4,5 numbers are in your List.
Then you’ve to make addition in following way,

  1. addition for no 1st —> i.e 2
    2+3, 2+4, 2+5
  2. And then then the addition for no 2nd —> i.e 3
    3+4, 3+5,
    and so on.
    For this you’ll need 2 while activities one inside other,
    first to increment 2nd no. and another to increment 1st no.

Take a look at this xaml and you’ll get the idea.

Main.xaml (9.7 KB)

@Ajju ok so first of all thank you for your reply very useful. But it doesn’t do all the combinations. Maybe cause i didn’t explain my self well. The process that i need needs to this calculation for list that are more than 3 numbers. if i put four numbers in the list like {1,2,3,4} the workflow does this:
and of course doesn’t do all the numbers together as you said
but it doesn’t do also like 2+3+4 or 1+2+3 or 1+3+4.
Having said that thank you very much for your workflow it defenetly will help @Ajju

Thank you for your reply @samir
but it’s the same thing it doesn’t do all the combination. It does only tuples, it doesn’t do like 2+3+4 or 3+4+5… And i need it not only to do tuples but the others aswell, input list length changes every time.

I’m not sure if this is even a process that i can make with uipath. Maybe with invoking VBA it’s easier but i don’t know the language :upside_down_face: and in another post they’ve linked a vba code that is supposed to do this operation but when i copy it it gives me like 1000 errors :rofl:. This is the link if anyone can help me understand it it will do me a big favor.

@Mustafa_Hamed you can do this with a list easily enough - no guarantees this is the fastest/best way but it should work fine. It uses 2 nested for each loops and an if statement.

I’ll assume your list is of type integer and is called MyList.
I’ll assume you display your total in an integer variable i call MyTotal

For each FirstNum in MyList  // make sure this is of type integer
  For each SecondNum in MyList  //  make sure this is of type integer
    If MyList.IndexOf(SecondNum) > MyList.IndexOf(FirstNum)
      THEN Assign MyTotal = MyTotal + FirstNum + SecondNum
      ELSE (leave blank)
    End if
  Next SecondNum
Next FirstNum

EDIT: I can attach as a workflow file if you want, but this is pretty easily adaptable into uipath, i just wrote it out in pseudo-code as that was easier for me. It just uses a 2 for each activities, 1 if activity, and 1 assign activity