aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-012/massa/README1
-rw-r--r--challenge-012/massa/raku/ch-1.raku48
-rw-r--r--challenge-012/massa/raku/ch-2.raku60
-rw-r--r--challenge-263/ash/perl/ch-2.pl31
-rw-r--r--challenge-263/ash/raku/ch-2.raku16
-rw-r--r--challenge-263/athanasius/perl/ch-1.pl189
-rw-r--r--challenge-263/athanasius/perl/ch-2.pl240
-rw-r--r--challenge-263/athanasius/raku/ch-1.raku160
-rw-r--r--challenge-263/athanasius/raku/ch-2.raku225
-rw-r--r--challenge-263/bruce-gray/raku/ch-1.raku13
-rw-r--r--challenge-263/bruce-gray/raku/ch-2.raku29
-rw-r--r--challenge-263/dave-jacoby/blog.txt1
-rw-r--r--challenge-263/dave-jacoby/perl/ch-1.pl30
-rw-r--r--challenge-263/dave-jacoby/perl/ch-2.pl48
-rw-r--r--challenge-263/dave-jacoby/python/ch-1.py24
-rwxr-xr-xchallenge-263/e-choroba/perl/ch-1.pl62
-rwxr-xr-xchallenge-263/e-choroba/perl/ch-2.pl30
-rw-r--r--challenge-263/massa/raku/ch-1.raku64
-rw-r--r--challenge-263/massa/raku/ch-2.raku69
-rwxr-xr-xchallenge-263/mattneleigh/perl/ch-1.pl90
-rwxr-xr-xchallenge-263/mattneleigh/perl/ch-2.pl132
-rw-r--r--challenge-263/peter-campbell-smith/blog.txt1
-rwxr-xr-xchallenge-263/peter-campbell-smith/perl/ch-1.pl42
-rwxr-xr-xchallenge-263/peter-campbell-smith/perl/ch-2.pl41
-rw-r--r--challenge-263/pokgopun/go/ch-1.go76
-rw-r--r--challenge-263/pokgopun/go/ch-2.go96
-rw-r--r--challenge-263/pokgopun/python/ch-1.py59
-rw-r--r--challenge-263/pokgopun/python/ch-2.py62
-rwxr-xr-xchallenge-263/roger-bell-west/javascript/ch-1.js63
-rwxr-xr-xchallenge-263/roger-bell-west/javascript/ch-2.js64
-rw-r--r--challenge-263/roger-bell-west/kotlin/ch-1.kt33
-rw-r--r--challenge-263/roger-bell-west/kotlin/ch-2.kt33
-rwxr-xr-xchallenge-263/roger-bell-west/lua/ch-1.lua64
-rwxr-xr-xchallenge-263/roger-bell-west/lua/ch-2.lua74
-rwxr-xr-xchallenge-263/roger-bell-west/perl/ch-1.pl16
-rwxr-xr-xchallenge-263/roger-bell-west/perl/ch-2.pl21
-rw-r--r--challenge-263/roger-bell-west/postscript/ch-1.ps235
-rw-r--r--challenge-263/roger-bell-west/postscript/ch-2.ps225
-rwxr-xr-xchallenge-263/roger-bell-west/python/ch-1.py21
-rwxr-xr-xchallenge-263/roger-bell-west/python/ch-2.py28
-rwxr-xr-xchallenge-263/roger-bell-west/raku/ch-1.p614
-rwxr-xr-xchallenge-263/roger-bell-west/raku/ch-2.p619
-rwxr-xr-xchallenge-263/roger-bell-west/ruby/ch-1.rb30
-rwxr-xr-xchallenge-263/roger-bell-west/ruby/ch-2.rb29
-rwxr-xr-xchallenge-263/roger-bell-west/rust/ch-1.rs27
-rwxr-xr-xchallenge-263/roger-bell-west/rust/ch-2.rs46
-rw-r--r--challenge-263/roger-bell-west/scala/ch-1.scala35
-rw-r--r--challenge-263/roger-bell-west/scala/ch-2.scala36
-rw-r--r--challenge-263/roger-bell-west/tests.yaml96
-rwxr-xr-xchallenge-263/ulrich-rieke/cpp/ch-1.cpp41
-rwxr-xr-xchallenge-263/ulrich-rieke/cpp/ch-2.cpp63
-rwxr-xr-xchallenge-263/ulrich-rieke/haskell/ch-1.hs17
-rwxr-xr-xchallenge-263/ulrich-rieke/haskell/ch-2.hs21
-rwxr-xr-xchallenge-263/ulrich-rieke/perl/ch-1.pl18
-rwxr-xr-xchallenge-263/ulrich-rieke/perl/ch-2.pl42
-rwxr-xr-xchallenge-263/ulrich-rieke/raku/ch-1.raku13
-rwxr-xr-xchallenge-263/ulrich-rieke/raku/ch-2.raku41
-rwxr-xr-xchallenge-263/ulrich-rieke/rust/ch-1.rs18
-rwxr-xr-xchallenge-263/ulrich-rieke/rust/ch-2.rs32
-rw-r--r--challenge-263/zapwai/c/ch-1.c50
-rw-r--r--challenge-263/zapwai/c/ch-2.c65
-rw-r--r--challenge-263/zapwai/javascript/ch-1.js15
-rw-r--r--challenge-263/zapwai/javascript/ch-2.js39
-rw-r--r--challenge-263/zapwai/perl/ch-1.pl14
-rw-r--r--challenge-263/zapwai/perl/ch-2.pl40
-rw-r--r--challenge-263/zapwai/python/ch-1.py15
-rw-r--r--challenge-263/zapwai/python/ch-2.py31
-rw-r--r--challenge-263/zapwai/rust/ch-1.rs20
-rw-r--r--challenge-263/zapwai/rust/ch-2.rs51
-rw-r--r--stats/pwc-current.json293
-rw-r--r--stats/pwc-language-breakdown-summary.json66
-rw-r--r--stats/pwc-language-breakdown.json1724
-rw-r--r--stats/pwc-leaders.json778
-rw-r--r--stats/pwc-summary-1-30.json48
-rw-r--r--stats/pwc-summary-121-150.json122
-rw-r--r--stats/pwc-summary-151-180.json50
-rw-r--r--stats/pwc-summary-181-210.json118
-rw-r--r--stats/pwc-summary-211-240.json50
-rw-r--r--stats/pwc-summary-241-270.json42
-rw-r--r--stats/pwc-summary-271-300.json54
-rw-r--r--stats/pwc-summary-301-330.json58
-rw-r--r--stats/pwc-summary-31-60.json102
-rw-r--r--stats/pwc-summary-61-90.json58
-rw-r--r--stats/pwc-summary-91-120.json42
-rw-r--r--stats/pwc-summary.json58
85 files changed, 5684 insertions, 1773 deletions
diff --git a/challenge-012/massa/README b/challenge-012/massa/README
new file mode 100644
index 0000000000..a7c2685bb7
--- /dev/null
+++ b/challenge-012/massa/README
@@ -0,0 +1 @@
+Solution by Massa 👽 Humberto
diff --git a/challenge-012/massa/raku/ch-1.raku b/challenge-012/massa/raku/ch-1.raku
new file mode 100644
index 0000000000..433e7afe08
--- /dev/null
+++ b/challenge-012/massa/raku/ch-1.raku
@@ -0,0 +1,48 @@
+#! /usr/bin/env raku
+
+# Perl Weekly Challenge
+# © 2023 Shimon Bollinger. All rights reserved.
+# Last modified: Mon 15 May 2023 09:17:32 PM EDT
+# Version 0.0.1
+
+=begin pod
+=TITLE
+=head2 Task 1: Euclid Number
+
+=SUBTITLE
+=head2 Submitted by massa
+
+=CHALLENGE
+=head2
+
+The numbers formed by adding one to the products of the smallest primes are
+called the Euclid Numbers (see wiki). Write a script that finds the smallest
+Euclid Number that is not prime. This challenge was proposed by Laurent
+Rosenfeld..
+
+=head3 Result
+
+ Output: 30031
+
+=SOLUTION
+
+=end pod
+
+# always use the latest version of Raku
+use v6.*;
+
+sub SOLUTION() {
+ ^∞ ==> grep &is-prime ==> produce &[*] ==> map {$_+1} ==> first {!.is-prime}
+}
+
+multi MAIN (Bool :$test!) {
+ use Testo;
+
+ my @tests =
+ %{ output => 30031 },
+ ;
+
+ SOLUTION().&is: .<output>, .<text> for @tests
+} # end of multi MAIN (Bool :$test!)
+
+
diff --git a/challenge-012/massa/raku/ch-2.raku b/challenge-012/massa/raku/ch-2.raku
new file mode 100644
index 0000000000..8e8fc20f7a
--- /dev/null
+++ b/challenge-012/massa/raku/ch-2.raku
@@ -0,0 +1,60 @@
+#! /usr/bin/env raku
+
+# Perl Weekly Challenge
+# © 2023 Shimon Bollinger. All rights reserved.
+# Last modified: Mon 15 May 2023 09:17:32 PM EDT
+# Version 0.0.1
+
+=begin pod
+=TITLE
+=head2 Task 1: Merge items
+
+=SUBTITLE
+=head2 Submitted by massa
+
+=CHALLENGE
+=head2
+
+You are given two 2-D array of positive integers, $items1 and $items2 where
+element is pair of (item_id, item_quantity).
+
+Write a script to return the merged items.
+
+=head3 Example 1:
+
+ Input: «/a/b/c/d /a/b/cd /a/b/cc /a/b/c/d/e»
+ Output: "/a/b"
+
+=SOLUTION
+
+=end pod
+
+# always use the latest version of Raku
+use v6.*;
+
+sub SOLUTION(*@paths is copy) {
+ my @parts = map { last unless [eq] $_[]; $_[0] }, [Z] (@paths ==> map {$*SPEC.splitdir: .IO});
+ $*SPEC.catdir: @parts
+}
+
+multi MAIN (Bool :$test!) {
+ use Testo;
+
+ my @tests =
+ %{ input => «/a/b/c/d /a/b/cd /a/b/cc /a/b/c/d/e»,
+ output => "/a/b" },
+ %{ input => «
+ /etc/apt/listchanges.conf.d /etc/apt/sources.list /etc/apt/sources.list.d
+ /etc/apt/sources.list.dpkg-backup /etc/apt/sources.list.save
+ /etc/apt/sources.list~ /etc/apt/apt.conf.d/20listchanges
+ /etc/apt/sources.list.d/google-chrome.list
+ /etc/apt/sources.list.d/google-chrome.list.save
+ /etc/apt/sources.list.d/nala-sources.list /etc/apt/sources.list.d/nala.list
+ /etc/apt/sources.list.d/steam.list.save »,
+ output => "/etc/apt" },
+ ;
+
+ SOLUTION(|.<input>).&is: .<output>, .<text> for @tests
+} # end of multi MAIN (Bool :$test!)
+
+
diff --git a/challenge-263/ash/perl/ch-2.pl b/challenge-263/ash/perl/ch-2.pl
new file mode 100644
index 0000000000..82804b51e6
--- /dev/null
+++ b/challenge-263/ash/perl/ch-2.pl
@@ -0,0 +1,31 @@
+# Solution to Task 2 of The Weekly Challenge 263
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-263/#TASK2
+
+# $ perl ch-2.pl
+# $VAR1 = [
+# [
+# 1,
+# 4
+# ],
+# [
+# 2,
+# 3
+# ],
+# [
+# 3,
+# 2
+# ]
+# ];
+
+use v5.20;
+use Data::Dumper;
+
+my $items1 = [[1, 1], [2, 1], [3, 2]];
+my $items2 = [[2, 2], [1, 3]];
+
+my %values;
+$values{$_->[0]} += $_->[1] for @$items1, @$items2;
+
+my @result = map {[$_ + 0, $values{$_}]} sort {$a <=> $b} keys %values;
+
+say Dumper(\@result);
diff --git a/challenge-263/ash/raku/ch-2.raku b/challenge-263/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..1df1d470c0
--- /dev/null
+++ b/challenge-263/ash/raku/ch-2.raku
@@ -0,0 +1,16 @@
+# Solution to Task 2 of The Weekly Challenge 263
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-263/#TASK2
+
+# $ raku ch-2.raku
+# [(1 4) (2 3) (3 2)]
+
+my @items1 = [[1, 1], [2, 1], [3, 2]];
+my @items2 = [[2, 2], [1, 3]];
+
+my %values;
+for (@items1, @items2).flat -> ($k, $v) {
+ %values{$k} += $v;
+}
+
+my @result = (%values.keys.sort: {$^a <=> $^b}).map: {$_, %values{$_}};
+say @result;
diff --git a/challenge-263/athanasius/perl/ch-1.pl b/challenge-263/athanasius/perl/ch-1.pl
new file mode 100644
index 0000000000..b14c9f23a2
--- /dev/null
+++ b/challenge-263/athanasius/perl/ch-1.pl
@@ -0,0 +1,189 @@
+#!perl
+
+################################################################################
+=comment
+
+Perl Weekly Challenge 263
+=========================
+
+TASK #1
+-------
+*Target Index*
+
+Submitted by: Mohammad Sajid Anwar
+
+You are given an array of integers, @ints and a target element $k.
+
+Write a script to return the list of indices in the sorted array where the
+element is same as the given target element.
+
+Example 1
+
+ Input: @ints = (1, 5, 3, 2, 4, 2), $k = 2
+ Output: (1, 2)
+
+ Sorted array: (1, 2, 2, 3, 4, 5)
+ Target indices: (1, 2) as $ints[1] = 2 and $k[2] = 2
+
+Example 2
+
+ Input: @ints = (1, 2, 4, 3, 5), $k = 6
+ Output: ()
+
+ No element in the given array matching the given target.
+
+Example 3
+
+ Input: @ints = (5, 3, 2, 4, 2, 1), $k = 4
+ Output: (4)
+
+ Sorted array: (1, 2, 2, 3, 4, 5)
+ Target index: (4) as $ints[4] = 4
+
+=cut
+################################################################################
+
+#--------------------------------------#
+# Copyright © 2024 PerlMonk Athanasius #
+#--------------------------------------#
+
+#===============================================================================
+=comment
+
+Interface
+---------
+1. If no command-line arguments are given, the test suite is run. Otherwise:
+2. The divisor $k is given on the command-line as a named argument, followed by
+ a (possibly empty) unnamed list of integers.
+3. If any integer in the list (i.e., following $k) on the command-line is
+ negative, the first such integer must be preceded by "--" to indicate that
+ what follows does not contain command-line flags.
+
+=cut
+#===============================================================================
+
+use v5.32.1; # Enables strictures
+use warnings;
+use Const::Fast;
+use Getopt::Long;
+use Regexp::Common qw( number );
+use Test::More;
+
+const my $USAGE => <<END;
+Usage:
+ perl $0 [-k[=Int]] [<ints> ...]
+ perl $0
+
+ -k[=Int] The target element
+ [<ints> ...] A list of integers
+END
+
+#-------------------------------------------------------------------------------
+BEGIN
+#-------------------------------------------------------------------------------
+{
+ $| = 1;
+ print "\nChallenge 263, Task #1: Target Index (Perl)\n\n";
+}
+
+#===============================================================================
+MAIN:
+#===============================================================================
+{
+ if (scalar @ARGV == 0)
+ {
+ run_tests();
+ }
+ else
+ {
+ my ($ints, $k) = parse_command_line();
+
+ printf "Input: \@ints = (%s), \$k = %d\n", join( ', ', @$ints ), $k;
+
+ my $indices = find_target_indices( $ints, $k );
+
+ printf "Output: (%s)\n", join ', ', @$indices;
+ }
+}
+
+#-------------------------------------------------------------------------------
+sub find_target_indices
+#-------------------------------------------------------------------------------
+{
+ my ($ints, $k) = @_;
+ my @sorted = sort { $a <=> $b } @$ints;
+ my @indices;
+
+ for my $i (0 .. $#sorted)
+ {
+ push @indices, $i if $sorted[ $i ] == $k;
+ }
+
+ return \@indices;
+}
+
+#-------------------------------------------------------------------------------
+sub parse_command_line
+#-------------------------------------------------------------------------------
+{
+ my $k;
+
+ GetOptions
+ (
+ 'k=i' => \$k,
+ ) or error( 'Invalid command line argument(s)' );
+
+ defined $k or error( '$k is missing' );
+
+ for (@ARGV, $k)
+ {
+ / ^ $RE{num}{int} $ /x or error( qq["$_" is not a valid integer] );
+ }
+
+ return (\@ARGV, $k);
+}
+
+#-------------------------------------------------------------------------------
+sub run_tests
+#-------------------------------------------------------------------------------
+{
+ print "Running the test suite\n";
+
+ while (my $line = <DATA>)
+ {
+ chomp $line;
+
+ my ($test_name, $ints_str, $k, $expected_str) = split / \| /x, $line;
+
+ for ($test_name, $ints_str, $k, $expected_str)
+ {
+ s/ ^ \s+ //x;
+ s/ \s+ $ //x;
+ }
+
+ my @ints = split / \s+ /x, $ints_str;
+ my @expected = split / \s+ /x, $expected_str;
+ my $indices = find_target_indices( \@ints, $k );
+
+ is_deeply $indices, \@expected, $test_name;
+ }
+
+ done_testing;
+}
+
+#-------------------------------------------------------------------------------
+sub error
+#-------------------------------------------------------------------------------
+{
+ my ($message) = @_;
+
+ die "ERROR: $message\n$USAGE";
+}
+
+################################################################################
+
+__DATA__
+Example 1| 1 5 3 2 4 2| 2|1 2
+Example 2| 1 2 4 3 5 | 6|
+Example 3| 5 3 2 4 2 1| 4|4
+Negatives|-1 -2 -3 0 4 -3|-3|0 1
diff --git a/challenge-263/athanasius/perl/ch-2.pl b/challenge-263/athanasius/perl/ch-2.pl
new file mode 100644
index 0000000000..356dcfca17
--- /dev/null
+++ b/challenge-263/athanasius/perl/ch-2.pl
@@ -0,0 +1,240 @@
+#!perl
+
+################################################################################
+=comment
+
+Perl Weekly Challenge 263
+=========================
+
+TASK #2
+-------
+*Merge Items*
+
+Submitted by: Mohammad Sajid Anwar
+
+You are given two 2-D array of positive integers, $items1 and $items2 where
+element is pair of (item_id, item_quantity).
+
+Write a script to return the merged items.
+
+Example 1
+
+ Input: $items1 = [ [1,1], [2,1], [3,2] ]
+ $items2 = [ [2,2], [1,3] ]
+ Output: [ [1,4], [2,3], [3,2] ]
+
+ Item id (1) appears 2 times: [1,1] and [1,3]. Merged item now (1,4)
+ Item id (2) appears 2 times: [2,1] and [2,2]. Merged item now (2,3)
+ Item id (3) appears 1 time: [3,2]
+
+Example 2
+
+ Input: $items1 = [ [1,2], [2,3], [1,3], [3,2] ]
+ $items2 = [ [3,1], [1,3] ]
+ Output: [ [1,8], [2,3], [3,3] ]
+
+Example 3
+
+ Input: $items1 = [ [1,1], [2,2], [3,3] ]
+ $items2 = [ [2,3], [2,4] ]
+ Output: [ [1,1], [2,9], [3,3] ]
+
+=cut
+################################################################################
+
+#--------------------------------------#
+# Copyright © 2024 PerlMonk Athanasius #
+#--------------------------------------#
+
+#===============================================================================
+=comment
+
+Assumption
+----------
+The "positive" integers include zero.
+
+Interface
+---------