aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-10-18 00:19:24 +0100
committerGitHub <noreply@github.com>2021-10-18 00:19:24 +0100
commitdd2ecf6aef6d5f746550dd7d016314a4b15b3cf2 (patch)
tree8fc489bc407139374544239b96c01a0a7d2232ae
parenta2b0e15f86badbf6ddf3626707de700546a4acee (diff)
parent3e191377825ad831a11e6465dc80e378c28c8848 (diff)
downloadperlweeklychallenge-club-dd2ecf6aef6d5f746550dd7d016314a4b15b3cf2.tar.gz
perlweeklychallenge-club-dd2ecf6aef6d5f746550dd7d016314a4b15b3cf2.tar.bz2
perlweeklychallenge-club-dd2ecf6aef6d5f746550dd7d016314a4b15b3cf2.zip
Merge pull request #5045 from rage311/134
Added task 1 for challenge 134
-rw-r--r--challenge-134/rage311/perl/ch-1.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/challenge-134/rage311/perl/ch-1.pl b/challenge-134/rage311/perl/ch-1.pl
new file mode 100644
index 0000000000..d53ac7230f
--- /dev/null
+++ b/challenge-134/rage311/perl/ch-1.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+
+use 5.034;
+use warnings;
+use feature 'signatures';
+no warnings 'experimental::signatures';
+
+sub pandigital ($base, $count) {
+ return if $count < 1;
+ my $prev =
+ (
+ ($base ** $base - $base)
+ / ($base - 1) ** 2
+ )
+ + ($base - 1)
+ * ($base ** ($base - 2))
+ - 1;
+
+ my @results = $prev;
+
+ while (@results < $count) {
+ my %digits;
+ my @chars = split //, ++$prev;
+ $digits{$_} = 1 for @chars;
+ next unless keys %digits == $base;
+ push @results, join '', @chars;
+ }
+
+ return @results;
+}
+
+say for pandigital(10, 10);