Note:After reading templatetypedef's post, it seems like I'm trying to compute the cartesian product of a set with itself a certain amount of times.
I am not completely sure what the problem I'm trying to solve is called, but it seems pretty close to permutation with replacement to me.
So basically, my problem is this. Given an array, for example:
{1, 2, 3} and a size, say 2. I need to output:
{1,1},{1,2},{1,3},{2,1},{2,2},... If size was 3, then it would be
{1,1,1},{1,1,2},{1,1,3},{1,2,1},{1,2,2},{1,2,3},{1,3,1}... How would I do this?
For the purposes of my problem, I have an input size of 15 numbers, so I guess I could create 15 for loops, but that seems like a hack to me.
Thanks.
Edit: I edited my problem after becoming not sure what I was asking and what I actually needed were essentially the same problem. After reading templatetypedef's post, it seems like i'm trying to compute the cartesian product of a set with itself size amount of times.