aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrage311 <rage_311@hotmail.com>2021-10-17 15:38:07 -0600
committerrage311 <rage_311@hotmail.com>2021-10-17 15:38:07 -0600
commit3e191377825ad831a11e6465dc80e378c28c8848 (patch)
tree8548245391286f659c09968d3a25046ad9dcdfb2
parent78cc5db60b6a54cd365b67b17013b72db7ed4268 (diff)
downloadperlweeklychallenge-club-3e191377825ad831a11e6465dc80e378c28c8848.tar.gz
perlweeklychallenge-club-3e191377825ad831a11e6465dc80e378c28c8848.tar.bz2
perlweeklychallenge-club-3e191377825ad831a11e6465dc80e378c28c8848.zip
Added ch-1
-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);