I had this question on the major exam

Q: devise an algorithm for generating all the r-combinations of a finite set when repetition is allowed.


my answer was a big space