If you're merely interested in finding permutations with a good 'score', and wish to avoid storing huge lists of permutations in memory, consider the simulated annealing algorithm: https://en.wikipedia.org/wiki/Simulated_annealing For this application, the algorithm involves repeatedly swapping two elements of the list to form new candidate solutions. If the score of the new list is better, it is accepted as the new solution. If the score of the new list is worse, it may still be accepted with a nonzero probability. The probability of a worse list being accepted decreases with higher score differential, and also with time (as the object 'cools', there is less 'energy' available to escape local minima). The output is a 'pretty good' solution, but there's no guarantee it will be the best.