Suppose I have two numbers, u and v, and a length n. I want to create all possible combinations of u and v that give me a vector length n, with repeats allowed. This gives different combinations. It is easier to show how this works with a couple of examples:
gives: [u u; u v; v u; v v], which is a matrix of length x n = 2 x 2.
gives: [u u u; u u v; u v u; u v v; v u u; v u v; v v u; v v v], which is a matrix of length 8 x 3.
There should be a pretty simple solution to this, but I'm having trouble using functions like perm or nchoosek to accomplish this. Thank you in advance!
Best Answer