From 5e4a64fd61cbdee9134be45992f77ae7806e2ce3 Mon Sep 17 00:00:00 2001 From: Alexander Pankoff Date: Sun, 1 Nov 2020 19:15:15 +0100 Subject: make `combinations` total instead of `die`ing this now returns a empty list when no combinations can be build --- challenge-083/alexander-pankoff/perl/lib/Combinations.pm | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/challenge-083/alexander-pankoff/perl/lib/Combinations.pm b/challenge-083/alexander-pankoff/perl/lib/Combinations.pm index 73b22cfa65..2fb005c0a7 100644 --- a/challenge-083/alexander-pankoff/perl/lib/Combinations.pm +++ b/challenge-083/alexander-pankoff/perl/lib/Combinations.pm @@ -4,19 +4,13 @@ use warnings; use feature qw(signatures); no warnings 'experimental::signatures'; -use Carp qw(croak); - use Exporter qw(import); our @EXPORT_OK = qw(combinations); # returns possible combinations of $length elements from @pool. sub combinations ( $count, @pool ) { - croak "cannot build combinations with $count elements from a list of " - . scalar(@pool) - . " elements" - if $count > @pool; - return () if $count == 0; + return () if $count == 0 || $count > @pool; return map { [$_] } @pool if $count == 1; my @combinations; -- cgit