26 lines
925 B
Plaintext
26 lines
925 B
Plaintext
;Task:
|
|
Given non-negative integers <big> '''m''' </big> and <big> '''n'''</big>, generate all size <big> '''m''' </big> [http://mathworld.wolfram.com/Combination.html combinations] of the integers from <big> '''0'''</big> (zero) to <big> '''n-1''' </big> in sorted order (each combination is sorted and the entire table is sorted).
|
|
|
|
|
|
;Example:
|
|
<big>'''3'''</big> comb <big> '''5''' </big> is:
|
|
0 1 2
|
|
0 1 3
|
|
0 1 4
|
|
0 2 3
|
|
0 2 4
|
|
0 3 4
|
|
1 2 3
|
|
1 2 4
|
|
1 3 4
|
|
2 3 4
|
|
|
|
If it is more "natural" in your language to start counting from <big> '''1'''</big> (unity) instead of <big> '''0'''</big> (zero),
|
|
<br>the combinations can be of the integers from <big> '''1'''</big> to <big> '''n'''. </big>
|
|
|
|
|
|
;See also:
|
|
{{Template:Combinations and permutations}}
|
|
<br><br>
|
|
|