aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Bell_West <roger@firedrake.org>2021-07-21 18:28:58 +0100
committerRoger Bell_West <roger@firedrake.org>2021-07-21 18:28:58 +0100
commit8976ad613604aad9e0db9a6077bdecb04f2c2b10 (patch)
treef9c41c6225da52ab5f8b47e60ff36c06b9d845a7
parentf483958932205a86616cbd8b915cbfbb481cf17e (diff)
downloadperlweeklychallenge-club-8976ad613604aad9e0db9a6077bdecb04f2c2b10.tar.gz
perlweeklychallenge-club-8976ad613604aad9e0db9a6077bdecb04f2c2b10.tar.bz2
perlweeklychallenge-club-8976ad613604aad9e0db9a6077bdecb04f2c2b10.zip
Post-challenge bugfix, thanks Jörg
-rwxr-xr-xchallenge-121/roger-bell-west/perl/ch-2.pl7
1 files changed, 4 insertions, 3 deletions
diff --git a/challenge-121/roger-bell-west/perl/ch-2.pl b/challenge-121/roger-bell-west/perl/ch-2.pl
index 6d4878d398..5af7c07c41 100755
--- a/challenge-121/roger-bell-west/perl/ch-2.pl
+++ b/challenge-121/roger-bell-west/perl/ch-2.pl
@@ -22,7 +22,7 @@ is_deeply(tsp([
use YAML::XS;
print Dump(tsp(mkmatrix(10)));
-use Algorithm::Permute;
+use Algorithm::Combinatorics qw(combinations);
use List::Util qw(min);
sub tsp {
@@ -34,8 +34,9 @@ sub tsp {
$c{1<<$k}{$k}=[$d->[0][$k],0];
}
foreach my $ss (2..$n1) {
- my $p=Algorithm::Permute->new([1..$n1],$ss);
- while (my @s = $p->next) {
+ my $p=combinations([1..$n1],$ss);
+ while (my $ss = $p->next) {
+ my @s=@{$ss};
my $bits=0;
foreach my $bit (@s) {
$bits |= 1 << $bit;