Permutations

Blitz3D Forums/Blitz3D Programming/Permutations

virtlands(Posted 2013) [#1]
Hi, this research topic is on permutations and how to generate them.

I've searched the community code archives for this topic, and it looks lik I'm the first to try to generate permuation sets.

The algorithm to compute the number of n items taken k at a time, is the following:


Object order is important, and objects are not allowed to be repeated within a subset.

But the code to actually display all those permutations is much more complex.

I found a very quick algorithm in 'C' known as the "boothroyd" method,
so I translated it into Blit3D in this demonstration program.

I don't understand the boothroyd logic at all, but it works.



[screenshot of program output]


There are apparently times when the Function duplicates set listings,
as in you can obviously see that "ABC" is duplicated.

I made some small 'catch' code and added to "boothroyd_1A" to
avoid duplications...

I'll be back later. My goal is to create my own algorithm for creating permutations. So far, my own ideas didn't work,
but the "boothroyd" method does.

http://rosettacode.org/wiki/Permutations#C