Hi everyone,
So I'm hoping I am posting this question in the correct section.
Below I have written a small code example of what I am trying to do:
public class IteratingCombinationsManual {
public static void main(String[]args){
int combinations = 0;
for(int a = 1; a <= 3; a++){
for(int b = 1; b <= 3; b++){
for(int c = 1; c <= 3; c++){
System.out.println(c + "/" + b + "/" + a);
combinations++;
}
}
}
System.out.println("Combinations: " + combinations);
}
}
So the output will be 3 columns of numbers iterating through every combination you can have with 3 colmuns of numbers ranging from 1 to 3. My question is that my actual problem is I don't know how many columns there will be as the user will determine this so I can't hard code the number of embeded loops to match the number of columns and I was wondering if there is any known design patterns or methods to solve a problem like this. I've been trying to rack my brains with this for awhile and I'm starting to think it will have to be some sort of OO solution as opposed to just the correct arrangement of loops.
Any guidance or suggestions would be greatly appriciated.
Thanks.