diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-01-24 19:54:02 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-24 19:54:02 +0000 |
| commit | 9cd79667af6d42cb5032c121f40acf2e91d8ad38 (patch) | |
| tree | 3fb38b150c48aa4c93c98dbdc4b200a69f71bab7 | |
| parent | 092e53fa7335deeac05c85c055733255dd5c4c89 (diff) | |
| parent | 0c5aa2ba140523efe1b8732cd286114d1ac6b8ef (diff) | |
| download | perlweeklychallenge-club-9cd79667af6d42cb5032c121f40acf2e91d8ad38.tar.gz perlweeklychallenge-club-9cd79667af6d42cb5032c121f40acf2e91d8ad38.tar.bz2 perlweeklychallenge-club-9cd79667af6d42cb5032c121f40acf2e91d8ad38.zip | |
Merge pull request #11482 from jeffrey-pinyan-cleandns/new-branch
Jeffrey "japhy" Pinyan's Perl solutions to weekly challenge 305
| -rw-r--r-- | challenge-305/japhy/README | 1 | ||||
| -rw-r--r-- | challenge-305/japhy/perl/ch-1.pl | 14 | ||||
| -rw-r--r-- | challenge-305/japhy/perl/ch-2.pl | 10 |
3 files changed, 25 insertions, 0 deletions
diff --git a/challenge-305/japhy/README b/challenge-305/japhy/README new file mode 100644 index 0000000000..691f99b25a --- /dev/null +++ b/challenge-305/japhy/README @@ -0,0 +1 @@ +Solution by Jeffrey "japhy" Pinyan diff --git a/challenge-305/japhy/perl/ch-1.pl b/challenge-305/japhy/perl/ch-1.pl new file mode 100644 index 0000000000..0865bc5419 --- /dev/null +++ b/challenge-305/japhy/perl/ch-1.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl -l + +print join ", " => binprime(1, 0, 1); +print join ", " => binprime(1, 1, 0); +print join ", " => binprime(1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1); + +sub binprime { + my $n = 0; + map { + $n += $_[$_]; + $n <<= 1; + !((1 x ($n>>1)) =~ /^.$|^(..+)\1+$/); + } (0 .. $#_); +} diff --git a/challenge-305/japhy/perl/ch-2.pl b/challenge-305/japhy/perl/ch-2.pl new file mode 100644 index 0000000000..d69c645fe9 --- /dev/null +++ b/challenge-305/japhy/perl/ch-2.pl @@ -0,0 +1,10 @@ +#!/usr/bin/perl -l + +print join ", " => alien(["perl", "python", "raku"], [qw/h l a b y d e f g i r k m n o p q j s t u v w x c z/]); +print join ", " => alien(["the", "weekly", "challenge"], [qw/c o r l d a b t e f g h i j k m n p q s w u v x y z/]); + +sub alien { + my $D = join "", @{+pop}; + my $t = sub { local $_ = shift; eval "y/a-zA-Z/$D$D/"; $_ }; + return sort { $t->($a) cmp $t->($b) } @{+shift}; +} |
