Subject: | Incorrect reset for 'k from n' permutations |
When generating permutations for r elements of n, reset() method
"breaks" the object:
=====
use Algorithm::Permute;
my $p = Algorithm::Permute->new([1..4], 2);
$p->reset;
while (my @a = $p->next) {
print join(',', @a), "\n"
}
$p->reset;
print "##########\n";
while (my @a = $p->next) {
print join(',', @a), "\n";
}
=====
2,1
1,2
3,2
2,3
3,1
1,3
4,2
2,4
4,3
3,4
4,1
1,4
##########
4,1
1,4
=====
Looks like if reset() trims [1..4] to [1,4].