Get every possible combination of elements in a list

Hey Community.
So here is what I wanna do.

I have a List of ints and I want to compare every possible combination of the elements to an int.

For example. my List contains 2 ints, x and y. I also have an int z.

What I wanna do is check if:

z = x

or

z = y

or

z = x + y

or

z = y + x.

And if one of these returns true i wanna do some stuff.

Of cours my list does not always contain 2 elements but ranges from 1 to 6 elements… so yeah…

Little note: If my Lists contains 3 Elements, for example a, b and c I also wanna check the possibility:

z = a + b …without c…

Any ideas?

you need a loop inside a loop … something like this

var i:int;
var i2:int;

i=yourlist.length;
while(i>0){i--;
 
i2=yourlist.length;
while(i2>0){i2--;

// compare your suff here however ya like!!!!
if(yourlist*.z==yourlist[i2].x+yourlist[i2].y){*

print(“one of your z’s adds to x and y”);}

if(yourlist*.x==yourlist[i2].y){*
print(“one of your x’s equals one of your y’s” );}
}
}