Combinations: Difference between revisions

m
Spelling/grammar/aesthetics.
m (→‎{{header|Haskell}}: Added type signature, improved aesthetics)
m (Spelling/grammar/aesthetics.)
Line 1:
{{task}}Given non-negative integers <tt> m </tt> and <tt> n</tt> ,<tt> </tt>generate all size <tt> m </tt> combinations of the integers from<tt> 0 </tt>to <tt> n-1 </tt> in sorted order (each combination is sorted and the entire table is sorted).
{{task}}
For example, <tt> 3 comb 5 </tt> is
 
Given non-negative integers<tt> m </tt>and<tt> n</tt> ,<tt> </tt>generate all size<tt> m </tt>combinations of the integers from<tt> 0 </tt>to<tt> n-1 </tt>
in sorted order (each combination is sorted and the entire table is sorted).
For example,<tt> 3 comb 5 </tt>is
 
 
Line 17 ⟶ 14:
2 3 4
 
If it is more "natural" in your language to start counting from <tt> 1 </tt> instead of <tt> 0 </tt> the combinations can be of the integers from <tt> 1 </tt> to <tt> n</tt> .
 
=={{header|Haskell}}==
Line 55 ⟶ 52:
)
 
The <tt> M. </tt> uses memoization which greatly reduces the running time.
Anonymous user