yet another logic.

Posted by Sunil on Stack Overflow See other posts from Stack Overflow or by Sunil
Published on 2011-01-04T23:11:07Z Indexed on 2011/01/05 0:53 UTC
Read the original article Hit count: 128

Filed under:
|
|
|

I'm working on a research problem out of curiosity and I don't know how to program the logic that I've in mind. Let me explain it to you :

I've 4 vectors say for example,

v1 = 1 1 1 1
v2 = 2 2 2 2
v3 = 3 3 3 3
v4 = 4 4 4 4

Now what I want to do is to add them combination-wise. i.e

v12 = v1+v2
v13 = v1+v3
v14 = v1+v4
v23 = v2+v3
v24 = v2+v4
v34 = v3+v4

Till this step it is just fine. The problem/trick is now, at the end of each iteration I give the obtained vectors into a black box function and it returns only few of the vectors say v12, v13 and v34. Now, I want to add each of these vectors one vector from v1,v2,v3,v4 which it hasn't added before. For example v3 and v4 hasn't been added to v12 so I want to create v123 and v124. similarly for all the vectors like,

v12 should become :
v123 = v12+v3
v124 = v12+v4

v13 should become :
v132 // this should not occur because I already have v123
v134 = v13+v4;

v14,v23 and v24 cannot be considered because it was deleted in the black box function so all we have in our hands to work with is v12,v13 and v34.

v34 should become :
v341 // cannot occur because we have 134
v342 = v34+v2

It is important that I do not do all at one step at the start like for example I can do (4 choose 3) 4C3 and finish it off but I want to do it step by step at each iteration.

I've asked a modified version of this question before (without including the black box function) and got answers here. Can anybody tell me how to do it when the black box function is included ? A modification of the previous answer would also be great.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c++

Related posts about algorithm