diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-07-21 20:07:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-21 20:07:51 +0100 |
| commit | 788f5847f98d8f8a4a050595ed8eba5fcc9904b3 (patch) | |
| tree | 9792cae39e9be4c4c8b68312871de29faaccdf50 | |
| parent | d3cd5368385508e2be612bd5d8ce7904c426663f (diff) | |
| parent | 8976ad613604aad9e0db9a6077bdecb04f2c2b10 (diff) | |
| download | perlweeklychallenge-club-788f5847f98d8f8a4a050595ed8eba5fcc9904b3.tar.gz perlweeklychallenge-club-788f5847f98d8f8a4a050595ed8eba5fcc9904b3.tar.bz2 perlweeklychallenge-club-788f5847f98d8f8a4a050595ed8eba5fcc9904b3.zip | |
Merge pull request #4577 from Firedrake/rogerbw-post-121-bugfix
Post-challenge bugfix, thanks Jörg
| -rwxr-xr-x | challenge-121/roger-bell-west/perl/ch-2.pl | 7 |
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; |
