aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrir <rirans@comcast.net>2024-06-08 21:18:14 -0400
committerGitHub <noreply@github.com>2024-06-08 21:18:14 -0400
commit5eb6d19fc4e8896f088ac554115e4f859647fb51 (patch)
tree8d6d353c51c60ebd87687d0153d996a3a20f22f6
parent1479026d0ced20754383b592338fc692552ab21e (diff)
parent14e4db4d669770384019246cd819e0842cc67a4e (diff)
downloadperlweeklychallenge-club-5eb6d19fc4e8896f088ac554115e4f859647fb51.tar.gz
perlweeklychallenge-club-5eb6d19fc4e8896f088ac554115e4f859647fb51.tar.bz2
perlweeklychallenge-club-5eb6d19fc4e8896f088ac554115e4f859647fb51.zip
Merge branch 'manwar:master' into work
-rw-r--r--challenge-259/adam-russell/.gitignore3
-rw-r--r--challenge-259/adam-russell/twc.pdfbin67950 -> 0 bytes
-rw-r--r--challenge-272/adam-russell/blog.txt1
-rw-r--r--challenge-272/adam-russell/perl/ch-1.pl25
-rw-r--r--challenge-272/adam-russell/perl/ch-2.pl26
-rw-r--r--challenge-272/jo-37/blog.txt1
-rwxr-xr-xchallenge-272/jo-37/perl/ch-1.pl65
-rwxr-xr-xchallenge-272/jo-37/perl/ch-2.pl65
-rw-r--r--challenge-272/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-10.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-3.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-4.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-5.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-6.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-7.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-8.txt1
-rw-r--r--challenge-272/luca-ferrari/blog-9.txt1
-rw-r--r--challenge-272/luca-ferrari/pljava/pom.xml6
-rw-r--r--challenge-272/luca-ferrari/pljava/src/main/java/Task1.java56
-rw-r--r--challenge-272/luca-ferrari/pljava/src/main/java/Task2.java63
-rw-r--r--challenge-272/luca-ferrari/plperl/ch-1.plperl22
-rw-r--r--challenge-272/luca-ferrari/plperl/ch-2.plperl26
-rw-r--r--challenge-272/luca-ferrari/plpgsql/ch-1.sql16
-rw-r--r--challenge-272/luca-ferrari/plpgsql/ch-2.sql33
-rw-r--r--challenge-272/luca-ferrari/python/ch-1.py20
-rw-r--r--challenge-272/luca-ferrari/python/ch-2.py34
-rw-r--r--challenge-272/luca-ferrari/raku/ch-1.raku15
-rw-r--r--challenge-272/luca-ferrari/raku/ch-2.raku19
-rw-r--r--challenge-272/pokgopun/go/ch-1.go59
-rw-r--r--challenge-272/pokgopun/go/ch-2.go98
-rw-r--r--challenge-272/pokgopun/python/ch-1.py42
-rw-r--r--challenge-272/pokgopun/python/ch-2.py87
-rw-r--r--challenge-272/reinier-maliepaard/blog.txt1
-rw-r--r--challenge-272/reinier-maliepaard/perl/ch-1.pl53
-rw-r--r--challenge-272/reinier-maliepaard/perl/ch-2.pl60
-rw-r--r--challenge-272/reinier-maliepaard/perl/ch-2a.pl16
-rw-r--r--challenge-272/robbie-hatley/blog.txt1
-rwxr-xr-xchallenge-272/roger-bell-west/crystal/ch-1.cr15
-rwxr-xr-xchallenge-272/roger-bell-west/crystal/ch-2.cr22
-rwxr-xr-xchallenge-272/roger-bell-west/javascript/ch-1.js20
-rwxr-xr-xchallenge-272/roger-bell-west/javascript/ch-2.js39
-rw-r--r--challenge-272/roger-bell-west/kotlin/ch-1.kt20
-rw-r--r--challenge-272/roger-bell-west/kotlin/ch-2.kt30
-rwxr-xr-xchallenge-272/roger-bell-west/lua/ch-1.lua20
-rwxr-xr-xchallenge-272/roger-bell-west/lua/ch-2.lua43
-rwxr-xr-xchallenge-272/roger-bell-west/perl/ch-1.pl15
-rwxr-xr-xchallenge-272/roger-bell-west/perl/ch-2.pl20
-rw-r--r--challenge-272/roger-bell-west/postscript/ch-1.ps70
-rw-r--r--challenge-272/roger-bell-west/postscript/ch-2.ps75
-rwxr-xr-xchallenge-272/roger-bell-west/python/ch-1.py16
-rwxr-xr-xchallenge-272/roger-bell-west/python/ch-2.py36
-rwxr-xr-xchallenge-272/roger-bell-west/raku/ch-1.p613
-rwxr-xr-xchallenge-272/roger-bell-west/raku/ch-2.p618
-rwxr-xr-xchallenge-272/roger-bell-west/ruby/ch-1.rb19
-rwxr-xr-xchallenge-272/roger-bell-west/ruby/ch-2.rb27
-rwxr-xr-xchallenge-272/roger-bell-west/rust/ch-1.rs24
-rwxr-xr-xchallenge-272/roger-bell-west/rust/ch-2.rs25
-rw-r--r--challenge-272/roger-bell-west/scala/ch-1.scala20
-rw-r--r--challenge-272/roger-bell-west/scala/ch-2.scala32
-rw-r--r--challenge-272/roger-bell-west/tests.json29
-rw-r--r--challenge-272/wambash/raku/ch-1.raku16
-rw-r--r--challenge-272/wambash/raku/ch-2.raku21
-rw-r--r--stats/pwc-current.json326
-rw-r--r--stats/pwc-language-breakdown-summary.json72
-rw-r--r--stats/pwc-language-breakdown.json1910
-rw-r--r--stats/pwc-leaders.json496
-rw-r--r--stats/pwc-summary-1-30.json44
-rw-r--r--stats/pwc-summary-121-150.json112
-rw-r--r--stats/pwc-summary-151-180.json106
-rw-r--r--stats/pwc-summary-181-210.json48
-rw-r--r--stats/pwc-summary-211-240.json38
-rw-r--r--stats/pwc-summary-241-270.json48
-rw-r--r--stats/pwc-summary-271-300.json46
-rw-r--r--stats/pwc-summary-301-330.json44
-rw-r--r--stats/pwc-summary-31-60.json42
-rw-r--r--stats/pwc-summary-61-90.json36
-rw-r--r--stats/pwc-summary-91-120.json46
-rw-r--r--stats/pwc-summary.json76
79 files changed, 3404 insertions, 1694 deletions
diff --git a/challenge-259/adam-russell/.gitignore b/challenge-259/adam-russell/.gitignore
deleted file mode 100644
index d4e9a94d5e..0000000000
--- a/challenge-259/adam-russell/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.bbprojectd
-.RData
-.Rhistory
diff --git a/challenge-259/adam-russell/twc.pdf b/challenge-259/adam-russell/twc.pdf
deleted file mode 100644
index 181cc3d3fa..0000000000
--- a/challenge-259/adam-russell/twc.pdf
+++ /dev/null
Binary files differ
diff --git a/challenge-272/adam-russell/blog.txt b/challenge-272/adam-russell/blog.txt
new file mode 100644
index 0000000000..a791044ed5
--- /dev/null
+++ b/challenge-272/adam-russell/blog.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/perl/2024/06/08
diff --git a/challenge-272/adam-russell/perl/ch-1.pl b/challenge-272/adam-russell/perl/ch-1.pl
new file mode 100644
index 0000000000..3564f846ea
--- /dev/null
+++ b/challenge-272/adam-russell/perl/ch-1.pl
@@ -0,0 +1,25 @@
+
+
+use v5.38;
+
+
+sub defang{
+ my($c, $defanged) = @_;
+ $defanged = [] if !$defanged;
+ return $defanged if @{$c} == 0;
+ my $x = shift @{$c};
+ if($x eq q/./){
+ push @{$defanged}, q/[.]/;
+ }
+ else{
+ push @{$defanged}, $x;
+ }
+ defang($c, $defanged);
+}
+
+
+MAIN:{
+ say join(q//, @{defang([split //, q/1.1.1.1/])});
+ say join(q//, @{defang([split //, q/255.101.1.0/])});
+}
+
diff --git a/challenge-272/adam-russell/perl/ch-2.pl b/challenge-272/adam-russell/perl/ch-2.pl
new file mode 100644
index 0000000000..bbdb2ea352
--- /dev/null
+++ b/challenge-272/adam-russell/perl/ch-2.pl
@@ -0,0 +1,26 @@
+
+
+use v5.38;
+
+
+sub string_score{
+ my($s) = shift;
+ my $score = 0;
+ my @s = map {ord $_} split //, $s;
+ {
+ my $x = shift @s;
+ my $y = shift @s;
+ $score += abs($x - $y) if $x && $y;
+ unshift @s, $y;
+ redo if @s > 1;
+ }
+ return $score;
+}
+
+
+MAIN:{
+ say string_score q/hello/;
+ say string_score q/perl/;
+ say string_score q/raku/;
+}
+
diff --git a/challenge-272/jo-37/blog.txt b/challenge-272/jo-37/blog.txt
new file mode 100644
index 0000000000..39fed0c9b1
--- /dev/null
+++ b/challenge-272/jo-37/blog.txt
@@ -0,0 +1 @@
+https://github.sommrey.de/the-bears-den/2024/06/07/ch-272.html
diff --git a/challenge-272/jo-37/perl/ch-1.pl b/challenge-272/jo-37/perl/ch-1.pl
new file mode 100755
index 0000000000..9ec3849c1b
--- /dev/null
+++ b/challenge-272/jo-37/perl/ch-1.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -s
+
+use v5.24;
+use Test2::V0;
+use Regexp::Common 'net';
+
+our ($tests, $examples);
+
+run_tests() if $tests || $examples; # does not return
+
+die <<EOS unless @ARGV;
+usage: $0 [-examples] [-tests] [STR]
+
+-examples
+ run the examples from the challenge
+
+-tests
+ run some tests
+
+STR
+ "defang" string
+
+EOS
+
+
+### Input and Output
+
+say defang(shift);
+
+
+### Implementation
+#
+# For details see:
+# https://github.sommrey.de/the-bears-den/2024/06/07/ch-272.html#task-1
+
+
+sub defang {
+ return /^$RE{net}{IPv4}$/ &&
+
+ s([.])([.])gr
+
+ for shift;
+}
+
+
+### Examples and tests
+
+sub run_tests {
+ SKIP: {
+ skip "examples" unless $examples;
+
+ is defang("1.1.1.1"), "1[.]1[.]1[.]1", "example 1";
+ is defang("255.101.1.0"), "255[.]101[.]1[.]0", "example 2";
+ }
+
+ SKIP: {
+ skip "tests" unless $tests;
+
+ is defang("256.0.0.1"), F(), 'invalid address';
+ is defang("1.0.0.256"), F(), 'invalid address';
+ }
+
+ done_testing;
+ exit;
+}
diff --git a/challenge-272/jo-37/perl/ch-2.pl b/challenge-272/jo-37/perl/ch-2.pl
new file mode 100755
index 0000000000..7f1ee3903f
--- /dev/null
+++ b/challenge-272/jo-37/perl/ch-2.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -s
+
+use v5.24;
+use Test2::V0 '!float';
+use PDL;
+use PDL::NiceSlice;
+use PDL::Char;
+
+our ($tests, $examples);
+
+run_tests() if $tests || $examples; # does not return
+
+die <<EOS unless @ARGV;
+usage: $0 [-examples] [-tests] [STR]
+
+-examples
+ run the examples from the challenge
+
+-tests
+ run some tests
+
+-verbose
+ enable trace output
+
+STR
+ an ASCII string
+
+EOS
+
+
+### Input and Output
+
+say score(shift);
+
+
+### Implementation
+#
+# For details see:
+# https://github.sommrey.de/the-bears-den/2024/06/07/ch-272.html#task-2
+
+
+sub score {
+ my $s = PDL::Char->new(shift);
+ sum abs long($s(0:-2)) - long($s(1:-1));
+}
+
+
+### Examples and tests
+
+sub run_tests {
+ SKIP: {
+ skip "examples" unless $examples;
+
+ is score("hello"), 13, "example 1";
+ is score("perl"), 30, "example 2";
+ is score("raku"), 37, "example 3";
+ }
+
+ SKIP: {
+ skip "tests" unless $tests;
+ }
+
+ done_testing;
+ exit;
+}
diff --git a/challenge-272/luca-ferrari/blog-1.txt b/challenge-272/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..e7579f5b4b
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task1
diff --git a/challenge-272/luca-ferrari/blog-10.txt b/challenge-272/luca-ferrari/blog-10.txt
new file mode 100644
index 0000000000..eda35729fd
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-10.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/[= date -%]/PerlWeeklyChallenge272.html#task2pljava
diff --git a/challenge-272/luca-ferrari/blog-2.txt b/challenge-272/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..fc64e99089
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task2
diff --git a/challenge-272/luca-ferrari/blog-3.txt b/challenge-272/luca-ferrari/blog-3.txt
new file mode 100644
index 0000000000..6cb55cedef
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-3.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task1plperl
diff --git a/challenge-272/luca-ferrari/blog-4.txt b/challenge-272/luca-ferrari/blog-4.txt
new file mode 100644
index 0000000000..cb1275772f
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-4.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task2plperl
diff --git a/challenge-272/luca-ferrari/blog-5.txt b/challenge-272/luca-ferrari/blog-5.txt
new file mode 100644
index 0000000000..86a012d6e5
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-5.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task1plpgsql
diff --git a/challenge-272/luca-ferrari/blog-6.txt b/challenge-272/luca-ferrari/blog-6.txt
new file mode 100644
index 0000000000..403db8c903
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-6.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task2plpgsql
diff --git a/challenge-272/luca-ferrari/blog-7.txt b/challenge-272/luca-ferrari/blog-7.txt
new file mode 100644
index 0000000000..c2fb30cccc
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-7.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task1python
diff --git a/challenge-272/luca-ferrari/blog-8.txt b/challenge-272/luca-ferrari/blog-8.txt
new file mode 100644
index 0000000000..63130d622d
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-8.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task2python
diff --git a/challenge-272/luca-ferrari/blog-9.txt b/challenge-272/luca-ferrari/blog-9.txt
new file mode 100644
index 0000000000..ce0f7adec4
--- /dev/null
+++ b/challenge-272/luca-ferrari/blog-9.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/06/PerlWeeklyChallenge272.html#task1pljava
diff --git a/challenge-272/luca-ferrari/pljava/pom.xml b/challenge-272/luca-ferrari/pljava/pom.xml
index bf11a0cf59..88583e06f9 100644
--- a/challenge-272/luca-ferrari/pljava/pom.xml
+++ b/challenge-272/luca-ferrari/pljava/pom.xml
@@ -7,14 +7,14 @@
<groupId>PWC</groupId>
<artifactId>
- PWC271
+ PWC272
</artifactId>
<version>
1
</version>
- <name>Perl Weekly Challenge 271 with package PWC271</name>
- <description>Implementation of the tasks in PL/Java for PWC 271</description>
+ <name>Perl Weekly Challenge 272 with package PWC272</name>
+ <description>Implementation of the tasks in PL/Java for PWC 272</description>
<properties>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
diff --git a/challenge-272/luca-ferrari/pljava/src/main/java/Task1.java b/challenge-272/luca-ferrari/pljava/src/main/java/Task1.java
new file mode 100644
index 0000000000..8dddbce6c0
--- /dev/null
+++ b/challenge-272/luca-ferrari/pljava/src/main/java/Task1.java
@@ -0,0 +1,56 @@
+
+
+
+package PWC272;
+
+/**
+ * PL/Java implementation for PWC 272
+ * Task 1
+ * See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-272>
+ *
+ *
+ * To compile on the local machine:
+
+ $ export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ # if not already set
+ $ mvn clean build
+ $ scp target/PWC272-1.jar luca@rachel:/tmp
+
+
+ * To install into PostgreSQL execute:
+
+ select sqlj.install_jar( 'file:///tmp/PWC272-1.jar', 'PWC272', true );
+ select sqlj.set_classpath( 'public', 'PWC272' );
+
+ select pwc272.task2_pljava();
+
+ and then to redeploy:
+
+ select sqlj.replace_jar( 'file:///tmp/PWC272-1.jar', 'PWC272', true );
+
+*/
+
+import org.postgresql.pljava.*;
+import org.postgresql.pljava.annotation.Function;
+import static org.postgresql.pljava.annotation.Function.Effects.IMMUTABLE;
+import static org.postgresql.pljava.annotation.Function.OnNullInput.RETURNS_NULL;
+
+import java.util.*;
+import java.util.stream.*;
+import java.sql.SQLException;
+import java.util.logging.*;
+import java.sql.ResultSet;
+import java.sql.Date;
+
+ public class Task1 {
+
+ private final static Logger logger = Logger.getAnonymousLogger();
+
+ @Function( schema = "pwc272",
+ onNullInput = RETURNS_NULL,
+ effects = IMMUTABLE )
+ public static final String task1_pljava( String ip ) throws SQLException {
+ logger.log( Level.INFO, "Entering pwc272.task1_pljava" );
+
+ return ip.replaceAll( "\\.", "[.]" );
+ }
+}
diff --git a/challenge-272/luca-ferrari/pljava/src/main/java/Task2.java b/challenge-272/luca-ferrari/pljava/src/main/java/Task2.java
new file mode 100644
index 0000000000..4002c64b9d
--- /dev/null
+++ b/challenge-272/luca-ferrari/pljava/src/main/java/Task2.java
@@ -0,0 +1,63 @@
+
+
+
+package PWC272;
+
+/**
+ * PL/Java implementation for PWC 272
+ * Task 2
+ * See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-272>
+ *
+ *
+ * To compile on the local machine:
+
+ $ export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ # if not already set
+ $ mvn clean build
+ $ scp target/PWC272-1.jar luca@rachel:/tmp
+
+
+ * To install into PostgreSQL execute:
+
+ select sqlj.install_jar( 'file:///tmp/PWC272-1.jar', 'PWC272', true );
+ select sqlj.set_classpath( 'public', 'PWC272' );
+
+ select pwc272.task2_pljava();
+
+ and then to redeploy:
+
+ select sqlj.replace_jar( 'file:///tmp/PWC272-1.jar', 'PWC272', true );
+
+*/
+
+import org.postgresql.pljava.*;
+import org.pos