aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-10-18 07:17:15 +0100
committerGitHub <noreply@github.com>2021-10-18 07:17:15 +0100
commitff2d1c669e29be1cf48d7fda93162191377c1150 (patch)
tree1a94f94a0bb9f103abd9577125b7d9ba000704b4
parent0730b1d308e0f92ed9e2d38163508e30bfa7424e (diff)
parentcc8b92e5290b313d697326c785470f239684d1a9 (diff)
downloadperlweeklychallenge-club-ff2d1c669e29be1cf48d7fda93162191377c1150.tar.gz
perlweeklychallenge-club-ff2d1c669e29be1cf48d7fda93162191377c1150.tar.bz2
perlweeklychallenge-club-ff2d1c669e29be1cf48d7fda93162191377c1150.zip
Merge pull request #5050 from andemark/branch-for-challenge-134
off by 1 error fixed
-rw-r--r--challenge-134/mark-anderson/raku/ch-1.raku17
1 files changed, 7 insertions, 10 deletions
diff --git a/challenge-134/mark-anderson/raku/ch-1.raku b/challenge-134/mark-anderson/raku/ch-1.raku
index 232362cd0a..213a6e51ec 100644
--- a/challenge-134/mark-anderson/raku/ch-1.raku
+++ b/challenge-134/mark-anderson/raku/ch-1.raku
@@ -1,20 +1,17 @@
#!/usr/bin/env raku
-# This program only deals with pandigital numbers up to 9,876,543,210
-# (or up to the 3,265,920th)
+say pandigital(1..5);
+say pandigital(1, 1000000, 2000000, 3000000, 3265920);
-say pandigital(^5);
-say pandigital(0, 1000000, 2000000, 3000000, 3265919);
-
-sub pandigital(+$arr where 3265920 > .all)
+sub pandigital(+$arr where 3265920 >= .all)
{
- my @polys = |$arr.map(*.polymod(362880));
+ my @polys = |$arr.map(*.pred.polymod(362880));
- my $chunks := < 1023456789 2013456789 3012456789
+ my $starts := < 1023456789 2013456789 3012456789
4012356789 5012346789 6012345789
7012345689 8012345679 9012345678 >;
- my @pans = gather for $chunks.head.comb.permutations
+ my @pans = gather for $starts.head.comb.permutations
{
.take
}[@polys>>[0]]>>.join;
@@ -22,7 +19,7 @@ sub pandigital(+$arr where 3265920 > .all)
gather for @pans Z @polys
{
my $div = .tail.tail;
- .head .= trans($chunks[0] => $chunks[$div]) if $div;
+ .head .= trans($starts[0] => $starts[$div]) if $div;
take .head;
}
}