From 98703ba19ddd98fa66cb10d371c8746282ad6043 Mon Sep 17 00:00:00 2001 From: Ysmael Ebreo Date: Wed, 2 Sep 2020 23:08:22 +0800 Subject: perl solution ch#76-1 --- challenge-076/yet-ebreo/perl/ch-1.pl | 21 +++++++++++++++++++++ challenge-076/yet-ebreo/perl/ch-1a.pl | 13 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 challenge-076/yet-ebreo/perl/ch-1.pl create mode 100644 challenge-076/yet-ebreo/perl/ch-1a.pl 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 -- cgit