diff options
115 files changed, 7293 insertions, 3380 deletions
diff --git a/challenge-241/athanasius/perl/ch-2.pl b/challenge-241/athanasius/perl/ch-2.pl index 8dc37497d3..3417309a3b 100644 --- a/challenge-241/athanasius/perl/ch-2.pl +++ b/challenge-241/athanasius/perl/ch-2.pl @@ -64,7 +64,7 @@ BEGIN #------------------------------------------------------------------------------- { $| = 1; - print "\nChallenge 240, Task #2: Prime Order (Perl)\n\n"; + print "\nChallenge 241, Task #2: Prime Order (Perl)\n\n"; } #=============================================================================== diff --git a/challenge-241/matthias-muth/blog.txt b/challenge-241/matthias-muth/blog.txt new file mode 100644 index 0000000000..8db6d3085d --- /dev/null +++ b/challenge-241/matthias-muth/blog.txt @@ -0,0 +1 @@ +https://github.com/MatthiasMuth/perlweeklychallenge-club/tree/muthm-241/challenge-241/matthias-muth#readme diff --git a/challenge-242/clifton-wood/raku/ch-1.raku b/challenge-242/clifton-wood/raku/ch-1.raku new file mode 100644 index 0000000000..de234fc88c --- /dev/null +++ b/challenge-242/clifton-wood/raku/ch-1.raku @@ -0,0 +1,10 @@ +my %h; +my @a = <a b c>; +my @b = <b c f>; %h{ |@a, |@b } »=» 1; +my (@m-a, @m-b); +for %h.keys { + @m-a.push: $_ unless @a.first($_).defined; + @m-b.push: $_ unless @b.first($_).defined; +} +@m-a.gist.say; +@m-b.gist.say; diff --git a/challenge-242/clifton-wood/raku/ch-2.raku b/challenge-242/clifton-wood/raku/ch-2.raku new file mode 100644 index 0000000000..1831ded48e --- /dev/null +++ b/challenge-242/clifton-wood/raku/ch-2.raku @@ -0,0 +1,4 @@ +my @matrix = ([1, 1, 0], [1, 0, 1], [0, 0, 0]); +@matrix.map( *.reverse.map( *.not.Int ) ).gist.say + + diff --git a/challenge-242/e-choroba/perl/ch-1.pl b/challenge-242/e-choroba/perl/ch-1.pl new file mode 100755 index 0000000000..93b46b9b45 --- /dev/null +++ b/challenge-242/e-choroba/perl/ch-1.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +use Tie::IxHash; + +sub missing_members($arr1, $arr2) { + tie my %seen, 'Tie::IxHash'; + for my $i (0, 1) { + $seen{$_}[$i] = 1 for @{ ($arr1, $arr2)[$i] }; + } + my @missing = ([], []); + for my $e (keys %seen) { + push @{ $missing[ ! $seen{$e}[0] ] }, $e + unless 2 == grep $_, @{ $seen{$e} }; + } + return \@missing +} + +use Test2::V0; +plan 2 + 1; + +is missing_members([1, 2, 3], [2, 4, 6]), [[1, 3], [4, 6]], 'Example 1'; +is missing_members([1, 2, 3, 3], [1, 1, 2, 2]), [[3], []], 'Example 2'; +is missing_members([1, 1, 2, 2], [1, 2, 3, 3]), [[], [3]], 'First empty'; diff --git a/challenge-242/e-choroba/perl/ch-2.pl b/challenge-242/e-choroba/perl/ch-2.pl new file mode 100755 index 0000000000..199eb685ce --- /dev/null +++ b/challenge-242/e-choroba/perl/ch-2.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +use PDL; + +sub flip_matrix($m) { + ! pdl($m)->slice('-1:0:0') +} + +use Test::More tests => 3; + +is_deeply flip_matrix("[1 1 0]\n[0 1 1]\n[0 0 1]")->unpdl, + [[1, 0, 0], [0, 0, 1], [0, 1, 1]], + 'Unnamed example'; + +is_deeply flip_matrix([[1, 1, 0], [1, 0, 1], [0, 0, 0]])->unpdl, + [[1, 0, 0], [0, 1, 0], [1, 1, 1]], + 'Example 1'; + +is_deeply flip_matrix( + [[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 1], [1, 0, 1, 0]] +)->unpdl, + [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1], [1, 0, 1, 0]], + 'Example 2'; diff --git a/challenge-242/eric-cheung/python/ch-1.py b/challenge-242/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..b3d79cc846 --- /dev/null +++ b/challenge-242/eric-cheung/python/ch-1.py @@ -0,0 +1,20 @@ +
+## Example 1
+## arrNum_01 = [1, 2, 3]
+## arrNum_02 = [2, 4, 6]
+
+## Example 2
+arrNum_01 = [1, 2, 3, 3]
+arrNum_02 = [1, 1, 2, 2]
+
+arrOutput = []
+
+arrOutput_01 = [nLoop for nLoop in list(set(arrNum_01)) if nLoop not in list(set(arrNum_02))]
+if len(arrOutput_01) > 0:
+ arrOutput.append(arrOutput_01)
+
+arrOutput_02 = [n |
