04-26-2024, 11:26 PM (This post was last modified: 04-26-2024, 11:33 PM by bplus.)
(04-26-2024, 11:12 PM)PhilOfPerth Wrote: At the risk of hijacking Circlotron's post further, 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.
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.
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.
04-27-2024, 02:43 AM (This post was last modified: 04-27-2024, 08:00 AM by PhilOfPerth.
Edit Reason: Saw my boo-boo
)
(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, 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, 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.)
Please visit my Website at: http://oldendayskids.blogspot.com/