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/
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)
take 1
That does look fun 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.