Combinations with repetitions: Difference between revisions
Content added Content deleted
(Add Nimrod) |
(→{{header|Perl}}: Add a module) |
||
Line 1,189: | Line 1,189: | ||
There are 11440 ways to pick 7 out of 10</pre> |
There are 11440 ways to pick 7 out of 10</pre> |
||
With a module: |
|||
<lang perl>use Algorithm::Combinatorics qw/combinations_with_repetition/; |
|||
my $iter = combinations_with_repetition([qw/iced jam plain/], 2); |
|||
while (my $p = $iter->next) { |
|||
print "@$p\n"; |
|||
} |
|||
# Not an efficient way: generates them all in an array! |
|||
my $count =()= combinations_with_repetition([1..10],7); |
|||
print "There are $count ways to pick 7 out of 10\n";</lang> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |