4 thoughts on “Permutations and derangements

  1. hi, I really like your algorithm. did you come up with this yourself or is it based on some permutation theorem?

    • It’s my own child. :-)

      The original intent was not producing only permutation sets, but all possible contained groups and order of elements on the given list (e.g. [1,2,3] would also produce [2,3], [3,2], [3], etc). To achieve that just remove the constraint on the queue size before yielding the value.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>