
Math question
I'm not a math person so here's a puzzle for you:<BR>I need to create all the possible permutations of a set.<BR><BR>So far, I know that I have to loop the same number of times as the number of items in the set:<BR><BR>set(n)<BR><BR>for x=0 to n1<BR><BR>Here I need to calculate all the different permutations of n things taken x at a time.<BR><BR>next<BR><BR>Anyone have any ideas of how to create all the different permutation of n things taken x at at time?

Is this homework?
If so, I'd rather you write the code.<BR><BR>I'll give you hints, though:<BR><BR>If you take N things X at a time, the fastest way to code is with X nest loops. But the coding is ugly and complex. And doesn't work if you don't know ahead of time what X is.<BR><BR>If you don't know ahead of time what X is, then recursion is the best answer.<BR><BR>The trick, in VBScript coding, is figuring out how to pass the diminished set to the next level in the recursion. That is, after level 1 chooses one of the N items, how do you pass the entire setminus the chosen oneon to level 2? And after level 2 chooses another item, how do you pass the set minus two to the level 3? Etc.<BR><BR>Figure that out and you're home free.<BR><BR>

RE: Is this homework?
You gave me a chuckle. I'm 37.<BR><BR>It's for a hobby site I'm building for a friend.

RE: Is this homework?
magic squares can be created using recursion and permutations........check this out, maybe it will help:<BR><BR>http://personal.vsnl.com/erwin/magic.htm

Thanks BW and JSW <eot>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

