Package for Johnson Trotter permutations algorithm

Hi everyone

I’ve written an implementation of the Johnson Trotter algorithm in Elm, which allows you to get one permutation at a time, instead of getting them all at once. This allows you to stop permuting early, and avoid stack overflow / out of memory

https://package.elm-lang.org/packages/ceddlyburge/johnson-trotter/latest/

8 Likes

Just for fun I tried wrapping this in a LazyList abstraction (as it might be easier to work with):

https://ellie-app.com/mDLypsRB6XXa1

(If you want to crash your browser, uncomment the take 1 at the bottom)

1 Like

That does look fun :slight_smile:
Would it make sense to add this to the package? Feel free to open up a PR if so

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.