Generating combinations with repetitions

Tomaz Ficko tomaz.ficko at agroruse.si
Thu May 4 02:31:19 EDT 2000


Can someone post code for generating all combinations of k elements out of n
elements with repetitions.

Example:
elements = 1,2,3,4  and k=3

111, 112, 113, 114,
222, 221, 223, 224,
333, 331, 332, 334,
444, 441, 442, 443,
123, 124, 134, 234

Thanks.

Tomaz









More information about the Python-list mailing list