Skip to main content
GameDev.net gamedev.net
🔒 Locked

Algorithm for nPk permutations ?

Started by xxx_shinobi May 20, 2006 at 12:38 PM 2 replies 1.4k views
Original Post
xxx_shinobi
xxx_shinobi
Hello. I really need some algorithm for finding all nPk permutations (ordered sub-sets with lenght = k) Number of such permutations is n!/(n-k)! Thanks in advance.
Fruny
Fruny
If programming in C++, you can use the std::next_permutation and std::prev_permutation functions. The source code is available (in the header) in case you want to see the implementation (and thus the algorithm).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
xxx_shinobi
xxx_shinobi
Quote:
Original post by Fruny
If programming in C++, you can use the std::next_permutation and std::prev_permutation functions. The source code is available (in the header) in case you want to see the implementation (and thus the algorithm).



Is there something in .NET platform for nPk ?
Fruny
Fruny
Quote:
Original post by xxx_shinobi
Is there something in .NET platform for nPk ?


I don't know. I doubt it. Check the documentation.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.