Project Euler Homework
|
Public Member Functions | |
permutation (unsigned short *y, int a, int b) | |
void | swap (int a, int b) |
swap the a-th and b-th digits | |
void | printP () |
print the permutation | |
void | move_to (unsigned k) |
move to k-th permutation, destructive. |
Using the method of recursion: To find the permutation of N digits in numerical order:
When N>2:
Swap the k-th digit with the 1-st digit.
_0123456789 -> 1023456789 -> 2013456789 -> ... -> 9012345678
Indexing the lexicographic permutation: