in reply to All possible number combinations in perl
See, for example, GetNextPermute in Algorithm::Loops.
In your concrete case, you can also code the solution yourself by realizing that each of your numbers is either in the result or not. You seem to consider 12 and 21 to be the same. This means that for generating the result, you can count from 0 to 2 ** $n and use the bits to indicate which number should be included for the current result.
As your problem suspiciously sounds like homework, I won't post any code. If you post the code you've written and explain where your code goes wrong, you will likely receive more help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: All possible number combinations in perl
by austinj (Acolyte) on Jun 07, 2012 at 21:18 UTC | |
by BrowserUk (Patriarch) on Jun 07, 2012 at 21:30 UTC | |
by rovf (Priest) on Jun 08, 2012 at 09:27 UTC | |
|
Re^2: All possible number combinations in perl (NestedLoops)
by tye (Sage) on Jun 08, 2012 at 19:02 UTC |