Relative Content

Tag Archive for pythonalgorithmpermutationpython-itertools

How to generate permutations with constraints

I want to generate all possible lists of [“x”,”y”,”z”,1,2,3] that are ordered in ascending order. “x”, “y” and “z” can be any real numbers and so their order can be arbitrary. However, as 1<2<3, 1 must be before 2 and 2 must be before 3. So, for example, the permutation [“x”, 1, “y”, “z”, 2, 3] should be generated, but the permutation [“x”, 1, “y”, “z”, 3, 2] should not be generated.