Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to reorder string variable x factorial different ways?
#11
(04-26-2024, 11:12 PM)PhilOfPerth Wrote: At the risk of hijacking  Circlotron's post further,  Big Grin   thanks @bplus. I was aware of the permutatins thing and its associated problem with expansion, but couldn't see a way around it.
Not sure what you meant in your last line, about filing the data... could you elaborate a little? It sounds interesting.

because it does take so long to calculate all the permutaions of 10 items i saved the array calculated to a file
here, as i recall it took hours to calculate for 10 digits 0 to 9 starting at 0123456789
and ending at 9876543210

well the forum took 5 mins to tell me the file is too big, i wonder if it were zipped? brb

yep downloaded and checked, it appears to be all there in order. i found out i had a 9 digits file too.


Attached Files
.zip   10 Digit permutations.zip (Size: 9.68 MB / Downloads: 16)
b = b + ...
Reply
#12
(04-26-2024, 02:17 PM)bplus Wrote:
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.
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.  Smile
Reply
#13
oh then maybe it does run out of stack space, my version didn't but doesn't check for dups either, it uses single letters or digits, you can later sub in whole words for each letter or digit. so if you start with different elements you get no dups.
b = b + ...
Reply
#14
(04-26-2024, 11:26 PM)bplus Wrote:
(04-26-2024, 11:12 PM)PhilOfPerth Wrote: At the risk of hijacking  Circlotron's post further,  Big Grin   thanks @bplus. I was aware of the permutatins thing and its associated problem with expansion, but couldn't see a way around it.
Not sure what you meant in your last line, about filing the data... could you elaborate a little? It sounds interesting.

because it does take so long to calculate all the permutaions of 10 items i saved the array calculated to a file
here, as i recall it took hours to calculate for 10 digits 0 to 9 starting at 0123456789
and ending at 9876543210

well the forum took 5 mins to tell me the file is too big, i wonder if it were zipped? brb

yep downloaded and checked, it appears to be all there in order. i found out i had a 9 digits file too.



(04-26-2024, 11:26 PM)bplus Wrote:
(04-26-2024, 11:12 PM)PhilOfPerth Wrote: At the risk of hijacking  Circlotron's post further,  Big Grin   thanks @bplus. I was aware of the permutatins thing and its associated problem with expansion, but couldn't see a way around it.
Not sure what you meant in your last line, about filing the data... could you elaborate a little? It sounds interesting.

because it does take so long to calculate all the permutaions of 10 items i saved the array calculated to a file
here, as i recall it took hours to calculate for 10 digits 0 to 9 starting at 0123456789
and ending at 9876543210

well the forum took 5 mins to tell me the file is too big, i wonder if it were zipped? brb

yep downloaded and checked, it appears to be all there in order. i found out i had a 9 digits file too.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply




Users browsing this thread: 1 Guest(s)