aboutsummaryrefslogtreecommitdiff
path: root/challenge-127
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-08-30 13:01:49 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-08-30 13:01:49 +0100
commitcb8da72f6ed37eec366fb34253839ff119a89c19 (patch)
tree79282c6c49c49eaa6ada0a541d92b8233e8157a2 /challenge-127
parent903abdef122a8081f238f0b3a9e8c02c5929b2b8 (diff)
downloadperlweeklychallenge-club-cb8da72f6ed37eec366fb34253839ff119a89c19.tar.gz
perlweeklychallenge-club-cb8da72f6ed37eec366fb34253839ff119a89c19.tar.bz2
perlweeklychallenge-club-cb8da72f6ed37eec366fb34253839ff119a89c19.zip
- Added solutions by Laurent Rosenfeld.
Diffstat (limited to 'challenge-127')
-rw-r--r--challenge-127/laurent-rosenfeld/perl/ch-1.pl3
-rw-r--r--challenge-127/laurent-rosenfeld/raku/ch-1.raku7
2 files changed, 10 insertions, 0 deletions
diff --git a/challenge-127/laurent-rosenfeld/perl/ch-1.pl b/challenge-127/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..561e75359b
--- /dev/null
+++ b/challenge-127/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,3 @@
+use strict; use warnings; use feature “say”;
+
+sub isdisjoint { my ($s1, $s2) = @; my %h1 = map { $_ => 1 } @$s1; for my $d (@$s2) { return 0 if exists $h1{$d}; } return 1; } say isdisjoint [1, 2, 5, 3, 4], [4, 6, 7, 8, 9]; say isdisjoint [1, 3, 5, 7, 9], [0, 2, 4, 6, 8];
diff --git a/challenge-127/laurent-rosenfeld/raku/ch-1.raku b/challenge-127/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..312ad53fe6
--- /dev/null
+++ b/challenge-127/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,7 @@
+use v6;
+
+sub is-disjoint ($s1, $s2) {
+ return ($s1 (&) $s2).elems == 0 ?? 1 !! 0;
+}
+say is-disjoint (1, 2, 5, 3, 4), (4, 6, 7, 8, 9);
+say is-disjoint (1, 3, 5, 7, 9), (0, 2, 4, 6, 8);