I want to develop the following put can't get it right. I have a vector of N length. Each element can become 0 to K. Here N and K are given by the user. Now I'm trying to create a function in which I can walk through all possible solutions.
So let's say N is 4 and K = 2, then I want to loop through all possible permutations (?).
I want to fill a vector with 0000, test it then fill the vector with 1000, test it then 0100 etc.
It's important to know that 0100 and 0010 are different. As are 1100 and 0011 etc.
For extra notice this is what the loop should print (it really doesn't matter is 0001 or 1000 comes after 0000 etc as long as all different possible sequences come up).
0000, 1000, 0100, 0010, 0001, 1100, 1010, 1001, 1110, 1101, 0111, 0101, ....., 2012, 2211 etc..
I've tried a combination of for loops but can't really get it. The application is in C++
Please help, tnx