aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoelle Maslak <jmaslak@antelope.net>2023-12-20 19:53:33 -0700
committerGitHub <noreply@github.com>2023-12-20 19:53:33 -0700
commitac10d33ad4be2763bba001150bef6e838d017546 (patch)
treea465bedb1a1bbbe6380c3c169404bf4565b893c3
parent80750c8e164c159fe869b652be98a1eef64373dd (diff)
parent33f4358de5040ddc31b53689b6a781efbc2847c1 (diff)
downloadperlweeklychallenge-club-ac10d33ad4be2763bba001150bef6e838d017546.tar.gz
perlweeklychallenge-club-ac10d33ad4be2763bba001150bef6e838d017546.tar.bz2
perlweeklychallenge-club-ac10d33ad4be2763bba001150bef6e838d017546.zip
Merge branch 'manwar:master' into master
-rw-r--r--challenge-247/dave-jacoby/blog.txt1
-rw-r--r--challenge-247/dave-jacoby/perl/ch-1.pl62
-rw-r--r--challenge-247/dave-jacoby/perl/ch-2.pl32
-rw-r--r--challenge-248/bob-lied/README6
-rw-r--r--challenge-248/bob-lied/perl/ch-1.pl141
-rw-r--r--challenge-248/bob-lied/perl/ch-2.pl75
-rw-r--r--challenge-248/dave-jacoby/blog.txt1
-rw-r--r--challenge-248/dave-jacoby/perl/ch-1.pl41
-rw-r--r--challenge-248/dave-jacoby/perl/ch-2.pl59
-rwxr-xr-xchallenge-248/e-choroba/perl/ch-1.pl26
-rwxr-xr-xchallenge-248/e-choroba/perl/ch-2.pl38
-rwxr-xr-xchallenge-248/eric-cheung/python/ch-1.py21
-rwxr-xr-xchallenge-248/eric-cheung/python/ch-2.py13
-rw-r--r--challenge-248/jeanluc2020/blog-1.txt1
-rw-r--r--challenge-248/jeanluc2020/blog-2.txt1
-rwxr-xr-xchallenge-248/jeanluc2020/perl/ch-1.pl70
-rwxr-xr-xchallenge-248/jeanluc2020/perl/ch-2.pl74
-rwxr-xr-xchallenge-248/jeanluc2020/python/ch-1.py66
-rwxr-xr-xchallenge-248/jeanluc2020/python/ch-2.py71
-rw-r--r--challenge-248/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-248/laurent-rosenfeld/perl/ch-1.pl26
-rw-r--r--challenge-248/laurent-rosenfeld/raku/ch-1.raku22
-rw-r--r--challenge-248/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-3.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-4.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-5.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-6.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-7.txt1
-rw-r--r--challenge-248/luca-ferrari/blog-8.txt1
-rw-r--r--challenge-248/luca-ferrari/postgresql/ch-1.plperl52
-rw-r--r--challenge-248/luca-ferrari/postgresql/ch-1.sql31
-rw-r--r--challenge-248/luca-ferrari/postgresql/ch-2.plperl28
-rw-r--r--challenge-248/luca-ferrari/postgresql/ch-2.sql32
-rw-r--r--challenge-248/luca-ferrari/python/ch-1.py37
-rw-r--r--challenge-248/luca-ferrari/python/ch-2.py42
-rw-r--r--challenge-248/luca-ferrari/raku/ch-1.p624
-rw-r--r--challenge-248/luca-ferrari/raku/ch-2.p627
-rw-r--r--challenge-248/mark-anderson/raku/ch-1.raku46
-rw-r--r--challenge-248/mark-anderson/raku/ch-2.raku72
-rwxr-xr-xchallenge-248/mattneleigh/perl/ch-1.pl95
-rwxr-xr-xchallenge-248/mattneleigh/perl/ch-2.pl176
-rwxr-xr-xchallenge-248/perlboy1967/perl/ch-1.pl45
-rwxr-xr-xchallenge-248/perlboy1967/perl/ch-2.pl60
-rw-r--r--challenge-248/peter-campbell-smith/blog.txt1
-rwxr-xr-xchallenge-248/peter-campbell-smith/perl/ch-1.pl44
-rwxr-xr-xchallenge-248/peter-campbell-smith/perl/ch-2.pl57
-rwxr-xr-xchallenge-248/peter-meszaros/perl/ch-1.pl102
-rwxr-xr-xchallenge-248/peter-meszaros/perl/ch-2.pl80
-rw-r--r--challenge-248/pokgopun/go/ch-1.go95
-rw-r--r--challenge-248/pokgopun/go/ch-2.go109
-rw-r--r--challenge-248/pokgopun/python/ch-1.py59
-rw-r--r--challenge-248/pokgopun/python/ch-2.py91
-rwxr-xr-xchallenge-248/roger-bell-west/javascript/ch-1.js72
-rwxr-xr-xchallenge-248/roger-bell-west/javascript/ch-2.js61
-rw-r--r--challenge-248/roger-bell-west/kotlin/ch-1.kt47
-rw-r--r--challenge-248/roger-bell-west/kotlin/ch-2.kt34
-rwxr-xr-xchallenge-248/roger-bell-west/lua/ch-1.lua77
-rwxr-xr-xchallenge-248/roger-bell-west/lua/ch-2.lua63
-rwxr-xr-xchallenge-248/roger-bell-west/perl/ch-1.pl39
-rwxr-xr-xchallenge-248/roger-bell-west/perl/ch-2.pl28
-rw-r--r--challenge-248/roger-bell-west/postscript/ch-1.ps179
-rw-r--r--challenge-248/roger-bell-west/postscript/ch-2.ps125
-rwxr-xr-xchallenge-248/roger-bell-west/python/ch-1.py37
-rwxr-xr-xchallenge-248/roger-bell-west/python/ch-2.py26
-rwxr-xr-xchallenge-248/roger-bell-west/raku/ch-1.p636
-rwxr-xr-xchallenge-248/roger-bell-west/raku/ch-2.p626
-rwxr-xr-xchallenge-248/roger-bell-west/ruby/ch-1.rb44
-rwxr-xr-xchallenge-248/roger-bell-west/ruby/ch-2.rb34
-rwxr-xr-xchallenge-248/roger-bell-west/rust/ch-1.rs36
-rwxr-xr-xchallenge-248/roger-bell-west/rust/ch-2.rs30
-rw-r--r--challenge-248/roger-bell-west/scala/ch-1.scala48
-rw-r--r--challenge-248/roger-bell-west/scala/ch-2.scala35
-rw-r--r--challenge-248/roger-bell-west/tests.yaml78
-rwxr-xr-xchallenge-248/ulrich-rieke/cpp/ch-1.cpp52
-rwxr-xr-xchallenge-248/ulrich-rieke/cpp/ch-2.cpp59
-rwxr-xr-xchallenge-248/ulrich-rieke/haskell/ch-1.hs17
-rwxr-xr-xchallenge-248/ulrich-rieke/haskell/ch-2.hs41
-rwxr-xr-xchallenge-248/ulrich-rieke/perl/ch-1.pl34
-rwxr-xr-xchallenge-248/ulrich-rieke/perl/ch-2.pl34
-rwxr-xr-xchallenge-248/ulrich-rieke/raku/ch-1.raku28
-rwxr-xr-xchallenge-248/ulrich-rieke/raku/ch-2.raku29
-rwxr-xr-xchallenge-248/ulrich-rieke/rust/ch-1.rs31
-rwxr-xr-xchallenge-248/ulrich-rieke/rust/ch-2.rs42
-rw-r--r--challenge-248/wlmb/blog.txt1
-rwxr-xr-xchallenge-248/wlmb/perl/ch-1.pl15
-rwxr-xr-xchallenge-248/wlmb/perl/ch-2.pl16
-rw-r--r--challenge-248/zapwai/perl/ch-1.pl19
-rw-r--r--challenge-248/zapwai/perl/ch-2.pl28
-rw-r--r--stats/pwc-challenge-247.json518
-rw-r--r--stats/pwc-current.json335
-rw-r--r--stats/pwc-language-breakdown-summary.json68
-rw-r--r--stats/pwc-language-breakdown.json3365
-rw-r--r--stats/pwc-leaders.json450
-rw-r--r--stats/pwc-summary-1-30.json110
-rw-r--r--stats/pwc-summary-121-150.json112
-rw-r--r--stats/pwc-summary-151-180.json128
-rw-r--r--stats/pwc-summary-181-210.json42
-rw-r--r--stats/pwc-summary-211-240.json38
-rw-r--r--stats/pwc-summary-241-270.json112
-rw-r--r--stats/pwc-summary-271-300.json138
-rw-r--r--stats/pwc-summary-301-330.json22
-rw-r--r--stats/pwc-summary-31-60.json124
-rw-r--r--stats/pwc-summary-61-90.json124
-rw-r--r--stats/pwc-summary-91-120.json98
-rw-r--r--stats/pwc-summary.json714
106 files changed, 7276 insertions, 3084 deletions
diff --git a/challenge-247/dave-jacoby/blog.txt b/challenge-247/dave-jacoby/blog.txt
new file mode 100644
index 0000000000..6bd07983bc
--- /dev/null
+++ b/challenge-247/dave-jacoby/blog.txt
@@ -0,0 +1 @@
+https://jacoby.github.io/2023/12/11/partidges-and-pair-trees-weekly-challenge-247.html
diff --git a/challenge-247/dave-jacoby/perl/ch-1.pl b/challenge-247/dave-jacoby/perl/ch-1.pl
new file mode 100644
index 0000000000..d96619aa19
--- /dev/null
+++ b/challenge-247/dave-jacoby/perl/ch-1.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use experimental qw{ say postderef signatures state };
+
+my @examples = (
+
+ [
+ 'Mr. Wall',
+ 'Mrs. Wall',
+ 'Mr. Anwar',
+ 'Mrs. Anwar',
+ 'Mr. Conway',
+ 'Mr. Cross',
+ ],
+
+ [ 'Mr. Wall', 'Mrs. Wall', 'Mr. Anwar', ],
+);
+
+for my $example (@examples) {
+ my %output = secret_santa( $example->@* );
+ my $input = join ",\n\t",
+ map { qq{"$_"} } # quote surname
+ map { $_->[0] } # remove surname element
+ sort { $a->[1] cmp $b->[1] } # sort on surname
+ map { [ $_, ( reverse split /\s/, $_ )[0] ] } # start schartzian transform on surname
+ sort { $a cmp $b } $example->@*; # sort alphabetically for consistency
+ my $output = join "\n\t",
+ map { qq{$_ -> $output{$_}} } # combine santa and giftee
+ map { $_->[0] } # remove surname element
+ sort { $a->[1] cmp $b->[1] } # sort on surname
+ map { [ $_, ( reverse split /\s/, $_ )[0] ] } # start schartzian transform on surname
+ sort { $a cmp $b } keys %output; # sort alphabetically for consistency
+
+ say <<~"END";
+ Input: \$input = (
+ $input
+ );
+ Output:
+ $output
+ END
+
+}
+
+# 1) everybody gets matched
+# 2) nobody gets matched to themself
+sub secret_santa (@input) {
+ my %done;
+
+ for my $name (@input) {
+ my %chosen = reverse %done;
+ my @others =
+ sort { rand 10 <=> rand 10 }
+ grep { $_ ne $name } @input;
+ for my $giftee (@others) {
+ next if $chosen{$giftee};
+ $done{$name} = $giftee;
+ }
+ }
+ return %done;
+}
diff --git a/challenge-247/dave-jacoby/perl/ch-2.pl b/challenge-247/dave-jacoby/perl/ch-2.pl
new file mode 100644
index 0000000000..cdc7dabc15
--- /dev/null
+++ b/challenge-247/dave-jacoby/perl/ch-2.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use experimental qw{ say postderef signatures state };
+
+my @examples = (
+
+ 'abcdbca',
+ 'cdeabeabfcdfabgcd',
+);
+
+for my $e (@examples) {
+ my $output = most_frequent_letter_pair($e);
+
+ say <<~"END";
+ Input: \$input = '$e'
+ Output: '$output'
+ END
+}
+
+sub most_frequent_letter_pair ($string) {
+ my %data;
+ for my $i ( 0 .. -2 + length $string ) {
+ my $sub = substr $string, $i, 2;
+ $data{$sub}++;
+ }
+ # ($scalar) = @list will assign the first element in the list to $scalar
+ my ($first) = sort { $data{$b} <=> $data{$a} } # second sort on value
+ sort keys %data; # first sort on lexographic value
+ return $first;
+}
diff --git a/challenge-248/bob-lied/README b/challenge-248/bob-lied/README
index ddf6e99243..882a98a265 100644
--- a/challenge-248/bob-lied/README
+++ b/challenge-248/bob-lied/README
@@ -1,4 +1,4 @@
-Solutions to weekly challenge 247 by Bob Lied
+Solutions to weekly challenge 248 by Bob Lied
-https://perlweeklychallenge.org/blog/perl-weekly-challenge-247/
-https://github.com/boblied/perlweeklychallenge-club/tree/master/challenge-247/bob-lied
+https://perlweeklychallenge.org/blog/perl-weekly-challenge-248/
+https://github.com/boblied/perlweeklychallenge-club/tree/master/challenge-248/bob-lied
diff --git a/challenge-248/bob-lied/perl/ch-1.pl b/challenge-248/bob-lied/perl/ch-1.pl
new file mode 100644
index 0000000000..e202a54191
--- /dev/null
+++ b/challenge-248/bob-lied/perl/ch-1.pl
@@ -0,0 +1,141 @@
+#!/usr/bin/env perl
+# vim:set ts=4 sw=4 sts=4 et ai wm=0 nu:
+#=============================================================================
+# Copyright (c) 2023, Bob Lied
+#=============================================================================
+# ch-1.pl Perl Weekly Challenge 248 Task 1 Shortest Distance
+#=============================================================================
+# You are given a string and a character in the given string.
+# Write a script to return an array of integers of size same as length of
+# the given string such that:
+# distance[i] is the distance from index i to the closest occurence of
+# the given character in the given string.
+# The distance between two indices i and j is abs(i - j).
+# Example 1 Input: $str = "loveleetcode", $char = "e"
+# Output: (3,2,1,0,1,0,0,1,2,2,1,0)
+# The character 'e' appears at indices 3, 5, 6, and 11 (0-indexed).
+# The closest occurrence of 'e' for index 0 is at index 3,
+# so the distance is abs(0 - 3) = 3.
+# The closest occurrence of 'e' for index 1 is at index 3,
+# so the distance is abs(1 - 3) = 2.
+# For index 4, there is a tie between the 'e' at index 3 and 'e' at index 5,
+# but the distance is still the same: abs(4 - 3) == abs(4 - 5) = 1.
+# The closest occurrence of 'e' for index 8 is at index 6,
+# so the distance is abs(8 - 6) = 2.