I need algorithm for effective generation unique sorted permutations. It is for new kind of a neural network. Assume that we have N types of neurons (let it be 3 for example), they are connected togother. We need to generate and test all possible, but unique (to not spend time) networks. That is because repetition of order does not change network. We are interested only in unique neurons types fingerprint.
For example if we have network of 3 neurons (with 3 types) after 133 (first neoron of 1st type, second of - 3d, and third of - 3d), then 331 will not be valid because it is superfluous, we are cheked allready network with one neuron of 1st type and two of 3d types.
So all valid variations for network of 3 neorons with 3 possible types will be: 111 112 113 221 222 223 331 332 333 123
How to generate such permutations? (do not store all the intermediate values of the sequence, rather generate them as required)