How to reorder string variable x factorial different ways? - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: How to reorder string variable x factorial different ways? (/showthread.php?tid=2619) Pages:
1
2
|
RE: How to reorder string variable x factorial different ways? - bplus - 04-26-2024 (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. 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. RE: How to reorder string variable x factorial different ways? - SMcNeill - 04-27-2024 (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. RE: How to reorder string variable x factorial different ways? - bplus - 04-27-2024 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. RE: How to reorder string variable x factorial different ways? - PhilOfPerth - 04-27-2024 (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. (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. |