This is a problem statement in one of the online Judges for programming. I am looking for an algorithm that gives optimized solution, not the best solution.
I'm given a set of triplet of balls, each containing one each of colors red,blue and green. Each ball has a charge represented by an integer (it's different for individual balls). Now the energy of the triplet is calculated by multiplying the charges in the triplet.
I can exchange balls between two triplets (Of course of the same colours, a triplet is not supposed to have balls of same colour), but on exchanging the balls, the energy of the exchanged balls is increased by one.
There's one more addition to the statement, swapping balls between triplets also accumulates a constant energy E on the system for every swap (it's not counted in the energy due to charges of balls).
The purpose of the optimisation is to reduce the energy of the whole system by swapping balls between triplets and bring it to a minimum, ie the sum of the product of charges in all triplets has to be minimum. The program must log all the swaps and the output state.