Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Generating Permutations

Name: anon 2013-02-02 2:18

What would be the easiest way to generate an array of all of the possible permutations of a string which will be a various length. I'm using java if it matters

And no, this isn't homework.

Name: Anonymous 2013-02-02 2:39

Hard code all possible values as constants and use a table to look them up.

Name: Anonymous 2013-02-02 2:47

>>1

There's a relatively simple solution that involves recursion and mutable array swappings. To get it list of them you'll have to copy them out to a list of solutions. The very wonderful way implementation uses a coroutine, allowing iteration through all permutations using linear stack space.

Name: Anonymous 2013-02-02 3:59

Haskell has the permutations function in its standard library.

Name: Anonymous 2013-02-02 10:39

>>5
And subsequences. Isn't Haskell great?

Name: Anonymous 2013-02-02 15:19

lel

Name: Anonymous 2013-02-02 15:56

protip: there is a project euler with this problem, search for them solutions

Name: Anonymous 2013-08-31 20:34


Japanese customs allows me 3 bottles of booze.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List