This is my first post so i will try and make it as clear and easy to understand as possible.
I would like some help writing a method that should fill an int [] (1D) with all combinations of numbers from one to a give value. The values can be overwritten every time. As an example. If the array was length 3, I would like the progression of the array to look something like this:
111, 211, 121, 112, 221, 122, 212, 222, 311, 113, 131, 321, 132, 231, ......
I thought the best way to break it down might be to forgot about order (so if the array had been 211, 112 would be unnecessary) and then have a separate method to permute the array and every step. So the method I am looking to create would only need to make the array evolve something like this:
111 211 221 222 311 321 322 332 333
I could then simply run the permute method in between each of these array states.
I managed to make a method that showed:
111 211 112 121 221 122 212 222 322 223 232 332 233 323 333 433...
This had all the permutations (which isn't essential for what I am now looking to do) but when I coded it I didn't make the numbers actually go back and cover every combinations (e.g.: 311) (the difference between the numbers in my arrays was only of one each time)
Some background information: I am making a program that balances chemical reactions by adding the correct stoichiometric coefficients in front of every compound. eg: _H20 + _02 = _H2O2
and _ represents a location for a coefficient. I have a functioning method that checks if the equation is balanced and I need to manage to try every combination of constants until the equation is balance (or until a limit is reached). So i decided to do this with an int[] and the fill the equation coefficients from the array.
Im willing to post more information or detail about my program if it interests anyone of if it may help answer my question.
Thanks, looking forward to here your answers/oppinions.
Have a good one!