04-27-2024, 01:23 AM
(04-26-2024, 02:17 PM)bplus Wrote:And one more thing to keep in mind: What I offered not only does the permutations, but it also checks each permutation against all existing words, to make certain that there's no duplication involved. (For example "foo" is both "foo" and "foo", even if you swap the 2nd or 3rd letters.) I suppose a faster version would probably be to simply generate the list, sort it, and then remove duplicates from the sorted list, but I honestly wasn't thinking folks would be using the code provided for massive length words. Recursion has a limit to how deep it can go before you run out of stack space. Without testing, I figured what I had was good enough to work while within that given stack-limit.Quote:Edit: This worked when I used alpha chars, which is what I want) to do), but when I used anything longer than 7 characters, it gave no result.
these are permutations, there are n! for n elements
N! = 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, ....
that sequence expands faster than any x^n ie expedentially plus!
you propably didn't get results because you didn't wait long enough plus real easy to go beyond the limits of the type fairly quickly.
that routine steve provided i think was better than what i had, except maybe the non recursive one?
i filed the data for 10 letters or digits so i could use a substitution technique for 10 of anything without recalculating permutaions of 10 things because it takes so long.