aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-05-16 09:48:08 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-05-16 09:48:08 +0100
commitacd8814dd8cd5cdb42a126b8af6d8031a128c04e (patch)
treecef2c4a99523b10b54cf56c723b41093bc79fc17
parentcb9aa268345e2514562f7d033902f9e8d6d54f2a (diff)
downloadperlweeklychallenge-club-acd8814dd8cd5cdb42a126b8af6d8031a128c04e.tar.gz
perlweeklychallenge-club-acd8814dd8cd5cdb42a126b8af6d8031a128c04e.tar.bz2
perlweeklychallenge-club-acd8814dd8cd5cdb42a126b8af6d8031a128c04e.zip
- Tidied up Perl solution.
-rw-r--r--challenge-060/mohammad-anwar/perl/ch-2.pl8
1 files changed, 2 insertions, 6 deletions
diff --git a/challenge-060/mohammad-anwar/perl/ch-2.pl b/challenge-060/mohammad-anwar/perl/ch-2.pl
index 562bcca909..0df0431f0a 100644
--- a/challenge-060/mohammad-anwar/perl/ch-2.pl
+++ b/challenge-060/mohammad-anwar/perl/ch-2.pl
@@ -5,18 +5,14 @@ use warnings;
use Algorithm::Combinatorics qw(variations_with_repetition);
-my @n = (0, 1, 2, 5);
-my $x = 2;
-my $y = 21;
-
-my @numbers = find_numbers(\@n, $x, $y);
+my @numbers = find_numbers([0, 1, 2, 5], 2, 21);
print join(", ", @numbers), "\n";
sub find_numbers {
my ($n, $x, $y) = @_;
my @numbers = ();
- foreach my $number (variations_with_repetition(\@n, $x)) {
+ foreach my $number (variations_with_repetition($n, $x)) {
$number = join("", @$number) + 0;
next unless ((length($number) == $x) && ($number < $y));
push @numbers, $number;