aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2020-06-22 00:06:52 +0800
committerYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2020-06-22 00:06:52 +0800
commit97a9cfff449eef8a7770958c8233441a230b637d (patch)
treeb68a26840e88201d114aa8454294a4e90e5f7413
parent326e67d40e1725f1538b92d70ef729f3db4e2456 (diff)
downloadperlweeklychallenge-club-97a9cfff449eef8a7770958c8233441a230b637d.tar.gz
perlweeklychallenge-club-97a9cfff449eef8a7770958c8233441a230b637d.tar.bz2
perlweeklychallenge-club-97a9cfff449eef8a7770958c8233441a230b637d.zip
Added perl solution ch#65
-rw-r--r--challenge-065/yet-ebreo/perl/ch-1.pl12
-rw-r--r--challenge-065/yet-ebreo/perl/ch-2.pl23
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-065/yet-ebreo/perl/ch-1.pl b/challenge-065/yet-ebreo/perl/ch-1.pl
new file mode 100644
index 0000000000..702265d3e9
--- /dev/null
+++ b/challenge-065/yet-ebreo/perl/ch-1.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature 'say';
+
+my $digits = 3;
+my $sum = 4;
+
+for my $x (glob "{1,2,3,4,5,6,7,8,9,0}" x $digits) {
+ my $s = eval $x=~s/\B/\+/gr;
+ (length (int $x) == $digits) && ($s == $sum) && say $x
+} \ No newline at end of file
diff --git a/challenge-065/yet-ebreo/perl/ch-2.pl b/challenge-065/yet-ebreo/perl/ch-2.pl
new file mode 100644
index 0000000000..d307acdde7
--- /dev/null
+++ b/challenge-065/yet-ebreo/perl/ch-2.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature 'say';
+
+use Algorithm::Combinatorics qw(partitions);
+
+my $string = "abbaba";
+my @arr = $string =~/./g;
+my %hash = ();
+
+for my $arr ( partitions(\@arr) ) {
+ for my $elem (@{$arr}) {
+ my $w = join "", @{$elem};
+ if ($w =~ /^((.)(?1)\2|.?)$/ && $string =~/$w/) {
+ (length $w > 1) && !$hash{$w} && say $w;
+
+ }
+ $hash{$w}++;
+ }
+}
+
+