generates permutations with duplication for a set