aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-09-02 16:10:04 +0100
committerGitHub <noreply@github.com>2020-09-02 16:10:04 +0100
commita48ebcdfe57e3a2aae4d100b40362dc61939c15d (patch)
treedc3fe0335e1e9a58e2804588fdc5ca25b749e988
parentb339f4362ef0101425f8836826d735ebf16f85cb (diff)
parent98703ba19ddd98fa66cb10d371c8746282ad6043 (diff)
downloadperlweeklychallenge-club-a48ebcdfe57e3a2aae4d100b40362dc61939c15d.tar.gz
perlweeklychallenge-club-a48ebcdfe57e3a2aae4d100b40362dc61939c15d.tar.bz2
perlweeklychallenge-club-a48ebcdfe57e3a2aae4d100b40362dc61939c15d.zip
Merge pull request #2191 from Doomtrain14/master
perl solution ch#76-1
-rw-r--r--challenge-076/yet-ebreo/perl/ch-1.pl21
-rw-r--r--challenge-076/yet-ebreo/perl/ch-1a.pl13
2 files changed, 34 insertions, 0 deletions
diff --git a/challenge-076/yet-ebreo/perl/ch-1.pl b/challenge-076/yet-ebreo/perl/ch-1.pl
new file mode 100644
index 0000000000..38dfccb673
--- /dev/null
+++ b/challenge-076/yet-ebreo/perl/ch-1.pl
@@ -0,0 +1,21 @@
+#! /usr/bin/perl
+use strict;
+use feature 'say';
+
+my $N = $ARGV[0] || 9;
+
+for (2..$N/2) {
+ (1x$_) !~ /^1?$|^(11+?)\1+$/ && (1x($N - $_)) !~ /^1?$|^(11+?)\1+$/ && say "$_ + ".($N - $_)." = $N";
+}
+=begin
+perl ch-1.pl 90
+7 + 83 = 90
+11 + 79 = 90
+17 + 73 = 90
+19 + 71 = 90
+23 + 67 = 90
+29 + 61 = 90
+31 + 59 = 90
+37 + 53 = 90
+43 + 47 = 90
+=cut \ No newline at end of file
diff --git a/challenge-076/yet-ebreo/perl/ch-1a.pl b/challenge-076/yet-ebreo/perl/ch-1a.pl
new file mode 100644
index 0000000000..3d5dd32379
--- /dev/null
+++ b/challenge-076/yet-ebreo/perl/ch-1a.pl
@@ -0,0 +1,13 @@
+#! /usr/bin/perl
+use strict;
+use feature 'say';
+
+use Math::Prime::Util qw(partitions is_prime forpart);
+my $min = 1e9;
+my $res = "";
+my $N = $ARGV[0] || 9;
+$" = "+";
+
+forpart { (!grep !is_prime($_), @_ ) && ($#_ < $min) && (($min, $res) = ($#_,"@_=$N")) } $N;
+
+say $res \ No newline at end of file