aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-10-14 02:51:02 +0100
committerGitHub <noreply@github.com>2020-10-14 02:51:02 +0100
commita79356c855061562356e9b16907756a82b5f6f0f (patch)
treea1c6ebd1c1e97c9f5ccfe7a3a0afe5c0ad814dfa
parentdd23c77b3af620035d1bed1b3efc108bc65f1fde (diff)
parent6a7091fc5d3377840b1b80a755e5f5e0b0283cab (diff)
downloadperlweeklychallenge-club-a79356c855061562356e9b16907756a82b5f6f0f.tar.gz
perlweeklychallenge-club-a79356c855061562356e9b16907756a82b5f6f0f.tar.bz2
perlweeklychallenge-club-a79356c855061562356e9b16907756a82b5f6f0f.zip
Merge pull request #2513 from juliodcs/juliodcs-week82
add juliodcs solution for week82
-rw-r--r--challenge-082/juliodcs/perl/ch-1.pl13
-rw-r--r--challenge-082/juliodcs/perl/ch-2.pl11
-rw-r--r--challenge-082/juliodcs/perl/input3
-rw-r--r--challenge-082/juliodcs/raku/ch-1.raku15
-rw-r--r--challenge-082/juliodcs/raku/ch-2.raku9
-rw-r--r--challenge-082/juliodcs/raku/input3
6 files changed, 48 insertions, 6 deletions
diff --git a/challenge-082/juliodcs/perl/ch-1.pl b/challenge-082/juliodcs/perl/ch-1.pl
new file mode 100644
index 0000000000..fe761afdf8
--- /dev/null
+++ b/challenge-082/juliodcs/perl/ch-1.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+use experimental 'signatures';
+use feature 'say';
+
+sub factors_to_hash($num) {
+ map { $_ => undef } (grep { $num % $_ == 0 } (1 .. $num/2), $num)
+}
+
+my %a = factors_to_hash shift;
+my %b = factors_to_hash shift;
+
+say join q(, ), grep { exists $a{$_} } sort keys %b;
diff --git a/challenge-082/juliodcs/perl/ch-2.pl b/challenge-082/juliodcs/perl/ch-2.pl
new file mode 100644
index 0000000000..6480571850
--- /dev/null
+++ b/challenge-082/juliodcs/perl/ch-2.pl
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+use experimental 'signatures';
+use feature 'say';
+use experimental 'smartmatch';
+
+sub comparable($string) {
+ join q(), sort split m//, $string
+}
+
+say comparable(shift . shift) eq comparable(shift) ? 1 : 0;
diff --git a/challenge-082/juliodcs/perl/input b/challenge-082/juliodcs/perl/input
deleted file mode 100644
index 7c77fa54a9..0000000000
--- a/challenge-082/juliodcs/perl/input
+++ /dev/null
@@ -1,3 +0,0 @@
-West Side Story
-
-The award-winning adaptation of the classic romantic tragedy "Romeo and Juliet". The feuding families become two warring New York City gangs, the white Jets led by Riff and the Latino Sharks, led by Bernardo. Their hatred escalates to a point where neither can coexist with any form of understanding. But when Riff's best friend (and former Jet) Tony and Bernardo's younger sister Maria meet at a dance, no one can do anything to stop their love. Maria and Tony begin meeting in secret, planning to run away. Then the Sharks and Jets plan a rumble under the highway--whoever wins gains control of the streets. Maria sends Tony to stop it, hoping it can end the violence. It goes terribly wrong, and before the lovers know what's happened, tragedy strikes and doesn't stop until the climactic and heartbreaking ending. \ No newline at end of file
diff --git a/challenge-082/juliodcs/raku/ch-1.raku b/challenge-082/juliodcs/raku/ch-1.raku
new file mode 100644
index 0000000000..e6db426348
--- /dev/null
+++ b/challenge-082/juliodcs/raku/ch-1.raku
@@ -0,0 +1,15 @@
+#!/usr/bin/env raku
+
+# returns list of divisors
+sub prefix:<∕>(\num) {
+ (1 ... num/2, +num).grep: num %% *
+}
+
+# intersects and returns result as sorted list
+sub infix:<@∩>(\a, \b) {
+ (a ∩ b).keys.sort.list
+}
+
+sub MAIN(Int \a where * > 0, Int \b where * > 0) {
+ say ∕a @∩ ∕b
+}
diff --git a/challenge-082/juliodcs/raku/ch-2.raku b/challenge-082/juliodcs/raku/ch-2.raku
new file mode 100644
index 0000000000..2b4cfcc3ee
--- /dev/null
+++ b/challenge-082/juliodcs/raku/ch-2.raku
@@ -0,0 +1,9 @@
+#!/usr/bin/env raku
+
+sub infix:<≈≈>(Str \x, Str \y) is equiv(&[eq]) returns Bool {
+ x.ords.sort == y.ords.sort
+}
+
+sub MAIN(Str \a, Str \b, Str \c) {
+ say +(a ~ b ≈≈ c)
+}
diff --git a/challenge-082/juliodcs/raku/input b/challenge-082/juliodcs/raku/input
deleted file mode 100644
index 7c77fa54a9..0000000000
--- a/challenge-082/juliodcs/raku/input
+++ /dev/null
@@ -1,3 +0,0 @@
-West Side Story
-
-The award-winning adaptation of the classic romantic tragedy "Romeo and Juliet". The feuding families become two warring New York City gangs, the white Jets led by Riff and the Latino Sharks, led by Bernardo. Their hatred escalates to a point where neither can coexist with any form of understanding. But when Riff's best friend (and former Jet) Tony and Bernardo's younger sister Maria meet at a dance, no one can do anything to stop their love. Maria and Tony begin meeting in secret, planning to run away. Then the Sharks and Jets plan a rumble under the highway--whoever wins gains control of the streets. Maria sends Tony to stop it, hoping it can end the violence. It goes terribly wrong, and before the lovers know what's happened, tragedy strikes and doesn't stop until the climactic and heartbreaking ending. \ No newline at end of file