Refactor condition
Small optimization of tuplet error calculation
Dynamic programming instead of permutations to find optimal tuplets