Dynamic programming addition to permutations for tuplet filtering