diff options
| author | Julio <julio.dcs@gmail.com> | 2020-10-13 23:44:43 +0200 |
|---|---|---|
| committer | Julio <julio.dcs@gmail.com> | 2020-10-13 23:46:04 +0200 |
| commit | 6a7091fc5d3377840b1b80a755e5f5e0b0283cab (patch) | |
| tree | 29e733d997b8190e16bbd5c83909907e5d1c5f7b | |
| parent | 73bd8af8d58941b8066141bc3fc64cf4165d80b5 (diff) | |
| download | perlweeklychallenge-club-6a7091fc5d3377840b1b80a755e5f5e0b0283cab.tar.gz perlweeklychallenge-club-6a7091fc5d3377840b1b80a755e5f5e0b0283cab.tar.bz2 perlweeklychallenge-club-6a7091fc5d3377840b1b80a755e5f5e0b0283cab.zip | |
add juliodcs solution for week82
| -rw-r--r-- | challenge-082/juliodcs/perl/ch-1.pl | 13 | ||||
| -rw-r--r-- | challenge-082/juliodcs/perl/ch-2.pl | 11 | ||||
| -rw-r--r-- | challenge-082/juliodcs/perl/input | 3 | ||||
| -rw-r--r-- | challenge-082/juliodcs/raku/ch-1.raku | 15 | ||||
| -rw-r--r-- | challenge-082/juliodcs/raku/ch-2.raku | 9 | ||||
| -rw-r--r-- | challenge-082/juliodcs/raku/input | 3 |
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 |
