diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-04-11 17:29:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-11 17:29:32 +0100 |
| commit | 6150b90485dc26e2bff5b6b723cce0a739a00d8e (patch) | |
| tree | 48156329e7c40d11579ec0ddfaf733a5fecfdbbd | |
| parent | d27a93fc6fda833e39eeac456a979b5464d00f85 (diff) | |
| parent | 8aa868c5b8c67d6453303d441343ac9895cf5b69 (diff) | |
| download | perlweeklychallenge-club-6150b90485dc26e2bff5b6b723cce0a739a00d8e.tar.gz perlweeklychallenge-club-6150b90485dc26e2bff5b6b723cce0a739a00d8e.tar.bz2 perlweeklychallenge-club-6150b90485dc26e2bff5b6b723cce0a739a00d8e.zip | |
Merge pull request #3864 from andemark/branch-for-challenge-107
ch-1.raku again...
| -rw-r--r-- | challenge-107/mark-anderson/raku/ch-1.raku | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/challenge-107/mark-anderson/raku/ch-1.raku b/challenge-107/mark-anderson/raku/ch-1.raku index 559f74d305..816d8c0ca5 100644 --- a/challenge-107/mark-anderson/raku/ch-1.raku +++ b/challenge-107/mark-anderson/raku/ch-1.raku @@ -1,13 +1,34 @@ #!/usr/bin/env raku -say (^Inf).grep(&self-descriptive).head(3); +say (1..36).map(&self-descriptive).flat.head(3); -sub self-descriptive($n) +multi self-descriptive($base where * == 1|2|3|6) { - for ^$n.chars + Empty; +} + +multi self-descriptive($base where * == 4|5) +{ + my $start = (1 ~ 0 x $base - 1).parse-base($base); + my $end = ($base - 1 ~ 0 x $base - 1).parse-base($base); + + gather { - return False unless $n.substr($_, 1) == $n.indices($_); + while $start < $end + { + my $multiple = $start.base($base); + + take $multiple if all map + { + $multiple.substr($_, 1) == $multiple.indices($_) + }, ^$base; + + $start += $base; + } } +} - True; +multi self-descriptive($base) +{ + ($base - 4).base(36) ~ 21 ~ 0 x $base - 7 ~ 1000; } |
