PermutaTriangle/Permuta

Add a generic Avoiders class

Closed this issue · 3 comments

Add an Avoiders class to permuta.permutation_sets. It should take in a pattern (or a set of patterns) and some length (or a lower and an upper bound), and iterating through that class should give all permutations of the given length that avoid the specified patterns.

This should either replace the PermutationsAvoiding* classes in permuta.permutation_sets, or they should be merged into the Avoiders class as faster methods for specific patterns.

I thought about this, but was worried about circular class dependence stuff, I think the current methods should be the faster methods for these specific patterns, since the naive way would surely just check for avoidance.

Would this be good to implement as a keyword argument in Permutations as well?

i.e.

> permuta.Permutations(3,avoiding=[1,2,3])
Permutations of length 3 avoiding 123
> list(permuta.Permutations(3, avoiding=[1,2,3]))
[Permutation([1,3,2]),
Permutation([2,1,3]),
Permutation([2,3,1]),
Permutation([3,1,2]),
Permutation([3,2,1])]

Added AvoidanceClass class in #9

A simple version of this was implemented in 9e2440c