RosettaCodeData/Task/Combinations/00-TASK.txt

26 lines
925 B
Plaintext

;Task:
Given non-negative integers &nbsp; <big> '''m''' </big> &nbsp; and &nbsp; <big> '''n'''</big>, &nbsp; generate all size &nbsp; <big> '''m''' </big> &nbsp; [http://mathworld.wolfram.com/Combination.html combinations] &nbsp; of the integers from &nbsp; <big> '''0'''</big> &nbsp; (zero) &nbsp; to &nbsp; <big> '''n-1''' </big> &nbsp; in sorted order &nbsp; (each combination is sorted and the entire table is sorted).
;Example:
<big>'''3'''</big> &nbsp; comb &nbsp; <big> '''5''' </big> &nbsp; &nbsp; 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 &nbsp; <big> '''1'''</big> &nbsp; (unity) instead of &nbsp; <big> '''0'''</big> &nbsp; (zero),
<br>the combinations can be of the integers from &nbsp; <big> '''1'''</big> &nbsp; to &nbsp; <big> '''n'''. </big>
;See also:
{{Template:Combinations and permutations}}
<br><br>