I`m totally newbie in statistic and i would like to ask for help. I need to write a program for generating a list of numbers from a specific set and with some rules. For example, the allowed set is {1,2,4,5}.

Rules are: generated numbers must be 7 digits long, number 2 can be included exactly 2 times. Number 5 can be included exactly 3 times. Example of the result could be:

5551224

5515224

5512524

5512254

5512245

2555214

...

That means in every generated number, i need to have two numbers of 2, three numbers of 5, one 1 and one 4, in every combination.

Could someone help me with algorithm please or at least tell me what is a name of my problem so i could google it ?

Thanks a lot!