Solved using genetic algorithm