R
Robocop
Having just started using C again after some years off, i've been
stumped by a problem i think someone more experienced could probably
solve pretty easily. I have these 4 objects (vectors), and i want to
find a combination of these 4 objects into two pairs, where the sum of
a specific attribute of each vector in each pair comes closest to some
base value. So all i want to do is run through the permutations of
these 4 objects and find the combination that results in two pairs
looking as close as possible to some base value.
The only thing i could think of creating a temporary vector,
initiating it by just dumping in one permutation, then looping over my
vector with the 4 objects in it, doing different permutations,
comparing those to the values in the temporary vector, and if this
permutation is better, pushing back the current pair values into the
temporary vector. After all the looping is done, i would just use the
temporary vector as my best fits.
Could anyone think of a possible solution that is simpler? I'm
currently trying to implement this solution but it's not quite
working. Any comments would be greatly appreciated.
stumped by a problem i think someone more experienced could probably
solve pretty easily. I have these 4 objects (vectors), and i want to
find a combination of these 4 objects into two pairs, where the sum of
a specific attribute of each vector in each pair comes closest to some
base value. So all i want to do is run through the permutations of
these 4 objects and find the combination that results in two pairs
looking as close as possible to some base value.
The only thing i could think of creating a temporary vector,
initiating it by just dumping in one permutation, then looping over my
vector with the 4 objects in it, doing different permutations,
comparing those to the values in the temporary vector, and if this
permutation is better, pushing back the current pair values into the
temporary vector. After all the looping is done, i would just use the
temporary vector as my best fits.
Could anyone think of a possible solution that is simpler? I'm
currently trying to implement this solution but it's not quite
working. Any comments would be greatly appreciated.