From d104b1fc88f9f3d6cf3e4a720bb16b40358363b3 Mon Sep 17 00:00:00 2001 From: KjetilS Date: Thu, 3 Jul 2025 15:45:27 +0200 Subject: https://theweeklychallenge.org/blog/perl-weekly-challenge-328/ --- challenge-328/kjetillll/perl/ch-1.pl | 49 ++++++++++++++++++++++++++++++++++++ challenge-328/kjetillll/perl/ch-2.pl | 16 ++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 challenge-328/kjetillll/perl/ch-1.pl create mode 100644 challenge-328/kjetillll/perl/ch-2.pl diff --git a/challenge-328/kjetillll/perl/ch-1.pl b/challenge-328/kjetillll/perl/ch-1.pl new file mode 100644 index 0000000000..a5b617eee5 --- /dev/null +++ b/challenge-328/kjetillll/perl/ch-1.pl @@ -0,0 +1,49 @@ +sub f { + local $_ = pop; + 1 while s{ + (.?) + \? + (.?) + } + { + $1 + . + ( grep /[^$1$2 ]/, 'a' .. 'z' )[0] + . + $2 + }ex; + $_; +} + + +print f("a?z") eq "abz" ? "ok" : "err", "\n"; +print f("pe?k") eq "peak" ? "ok" : "err", "\n"; +print f("gra?te") eq "grabte" ? "ok" : "err", "\n"; +print f("a?????b") eq "ababacb" ? "ok" : "err", "\n"; +print f("?a?") eq "bab" ? "ok" : "err", "\n"; +print f("?") eq "a" ? "ok" : "err", "\n"; + +__END__ + +For speedup, should it be needed, on very long inputs with many '?' chars +and/or very many inputs, initialize once an @array or a %hash and replace +this construct: + +( grep /[^$1$2 ]/, 'a' .. 'z' )[0] + +with either this: + +$array[ ord($1||'a') ][ ord($2||'a') ] + +or this: + +$array[ ord($1||'a') * 128 + ord($2||'a') ] + +or this if you prefer hashes and accept a little slower lookup than arrays: + +$hash{ $1 || 'a', $2 || 'a' } + +where the array/hash contains a possible pre-calculated letter for all +26*26=676 possible combinations of the two a-z chars before and after the '?' +and default to 'a' if the '?' are at the beginning or end of the string. + diff --git a/challenge-328/kjetillll/perl/ch-2.pl b/challenge-328/kjetillll/perl/ch-2.pl new file mode 100644 index 0000000000..fb88fd4616 --- /dev/null +++ b/challenge-328/kjetillll/perl/ch-2.pl @@ -0,0 +1,16 @@ +use v5.10; + +sub f { + state $regex_list = join '|', map { uc.lc, lc.uc } 'a' .. 'z'; #Aa|aA|Bb|bB ... Zz|zZ + my $str = shift; + 1 while $str =~ s/$regex_list//g; + $str +} + + +print f( "WeEeekly" ) eq "Weekly" ? "ok\n" : "err\n"; +print f( "abBAdD" ) eq "" ? "ok\n" : "err\n"; +print f( "abc" ) eq "abc" ? "ok\n" : "err\n"; + +#'state' instead of 'my' inits $regex_list only once even though f() is called multiple times. +#It also makes $regex_list invisible outside of sub f. Needs at least 'v5.10' for 'state' to be available. -- cgit From 8ed259a8992aa04f7a7c6b01eecf122bc0c9eba7 Mon Sep 17 00:00:00 2001 From: Bob Lied Date: Thu, 3 Jul 2025 09:57:11 -0500 Subject: Week 328 solutions --- challenge-328/bob-lied/README.md | 6 +-- challenge-328/bob-lied/perl/ch-1.pl | 89 +++++++++++++++++++++++++++++++++++++ challenge-328/bob-lied/perl/ch-2.pl | 75 +++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 challenge-328/bob-lied/perl/ch-1.pl create mode 100644 challenge-328/bob-lied/perl/ch-2.pl diff --git a/challenge-328/bob-lied/README.md b/challenge-328/bob-lied/README.md index 13e20a4e1e..cd437b9597 100644 --- a/challenge-328/bob-lied/README.md +++ b/challenge-328/bob-lied/README.md @@ -1,4 +1,4 @@ -# Solutions to weekly challenge 327 by Bob Lied +# Solutions to weekly challenge 328 by Bob Lied -## [PWC](https://perlweeklychallenge.org/blog/perl-weekly-challenge-327/) -## [GitHub](https://github.com/boblied/perlweeklychallenge-club/tree/master/challenge-327/bob-lied) +## [PWC](https://perlweeklychallenge.org/blog/perl-weekly-challenge-328/) +## [GitHub](https://github.com/boblied/perlweeklychallenge-club/tree/master/challenge-328/bob-lied) diff --git a/challenge-328/bob-lied/perl/ch-1.pl b/challenge-328/bob-lied/perl/ch-1.pl new file mode 100644 index 0000000000..cf78001a3a --- /dev/null +++ b/challenge-328/bob-lied/perl/ch-1.pl @@ -0,0 +1,89 @@ +#!/usr/bin/env perl +# vim:set ts=4 sw=4 sts=4 et ai wm=0 nu: +#============================================================================= +# Copyright (c) 2025, Bob Lied +#============================================================================= +# ch-1.pl Perl Weekly Challenge 328 Task 1 Replace all ? +#============================================================================= +# You are given a string containing only lower case English letters and ?. +# Write a script to replace all ? in the given string so that the string +# doesn’t contain consecutive repeating characters. +# Example 1 Input: $str = "a?z" +# Output: "abz" +# There can be many strings, one of them is "abz". The choices are 'a' +# to 'z' but we can't use either 'a' or 'z' to replace the '?'. +# Example 2 Input: $str = "pe?k" +# Output: "peak" +# Example 3 Input: $str = "gra?te" +# Output: "grabte" +#============================================================================= + +use v5.40; + + +use Getopt::Long; +my $Verbose = false; +my $DoTest = false; +my $Benchmark = 0; + +GetOptions("test" => \$DoTest, "verbose" => \$Verbose, "benchmark:i" => \$Benchmark); +my $logger; +{ + use Log::Log4perl qw(:easy); + Log::Log4perl->easy_init({ level => ($Verbose ? $DEBUG : $INFO ), + layout => "%d{HH:mm:ss.SSS} %p{1} %m%n" }); + $logger = Log::Log4perl->get_logger(); +} +#============================================================================= + +my %replace = ( "a?a" => "b", "a?b" => "c", + "b?b" => "a", "b?a" => "c", ); + +exit(!runTest()) if $DoTest; +exit( runBenchmark($Benchmark) ) if $Benchmark; + +say replaceQ($_) for @ARGV; + +#============================================================================= +sub replaceQ($str) +{ + my $pos = 0; + while ( ($pos = index($str, "?", $pos)) != -1 ) + { + my $before = substr($str, $pos-1, 1); + my $after = substr($str, $pos+1, 1); + + my $instead = ( $before eq 'a' || $after eq 'a' ) ? 'b' : 'a'; + $instead = 'c' if ( $before eq $instead || $after eq $instead ); + + substr($str, $pos, 1, $instead); + } + return $str; +} + +sub runTest +{ + use Test2::V0; + + is( replaceQ("a?z" ), "abz" , "Example 1"); + is( replaceQ("pe?k" ), "peak" , "Example 2"); + is( replaceQ("gra?te"), "grabte", "Example 3"); + + is( replaceQ("abcde" ), "abcde" , "No question marks"); + is( replaceQ("?abcd" ), "babcd" , "Leading"); + is( replaceQ("abcd?" ), "abcda" , "Trailing"); + is( replaceQ("a?b" ), "acb" , "Can't be a or b"); + is( replaceQ("x???z" ), "xabaz" , "Multiple question marks"); + + done_testing; +} + +sub runBenchmark($repeat) +{ +use Benchmark qw/cmpthese/; + +cmpthese($repeat, { +label => sub { }, +}); +} + diff --git a/challenge-328/bob-lied/perl/ch-2.pl b/challenge-328/bob-lied/perl/ch-2.pl new file mode 100644 index 0000000000..476d78d97e --- /dev/null +++ b/challenge-328/bob-lied/perl/ch-2.pl @@ -0,0 +1,75 @@ +#!/usr/bin/env perl +# vim:set ts=4 sw=4 sts=4 et ai wm=0 nu: +#============================================================================= +# Copyright (c) 2025, Bob Lied +#============================================================================= +# ch-2.pl Perl Weekly Challenge 328 Task 2 Good String +#============================================================================= +# You are given a string made up of lower and upper case English letters only. +# Write a script to return the good string of the given string. A string is +# called good string if it doesn’t have two adjacent same characters, one in +# upper case and other is lower case. +# Example 1 Input: $str = "WeEeekly" +# Output: "Weekly" +# We can remove either, "eE" or "Ee" to make it good. +# Example 2 Input: $str = "abBAdD" +# Output: "" +# We remove "bB" first: "aAdD". Then we remove "aA": "dD" Finally remove "dD". +# Example 3 Input: $str = "abc" +# Output: "abc" +#============================================================================= + +use v5.40; + + +use Getopt::Long; +my $Verbose = false; +my $DoTest = false; +my $Benchmark = 0; + +GetOptions("test" => \$DoTest, "verbose" => \$Verbose, "benchmark:i" => \$Benchmark); +my $logger; +{ + use Log::Log4perl qw(:easy); + Log::Log4perl->easy_init({ level => ($Verbose ? $DEBUG : $INFO ), + layout => "%d{HH:mm:ss.SSS} %p{1} %m%n" }); + $logger = Log::Log4perl->get_logger(); +} +#============================================================================= + +# Generate the regular expression "aA|Aa|bB|Bb|...|Zz" +my $ToBeRemoved = join("|", map { my $uc=uc($_); "$_$uc", "$uc$_" } 'a' .. 'z'); + +exit(!runTest()) if $DoTest; +exit( runBenchmark($Benchmark) ) if $Benchmark; + +say enGooden($_) for @ARGV; + +#============================================================================= +sub enGooden($str) +{ + while ( $str =~ s/$ToBeRemoved//g ) { } + return $str; +} + +sub runTest +{ + use Test2::V0; + + is( enGooden("WeEeekly"), "Weekly", "Example 1"); + is( enGooden("abBAdD"), "", "Example 2"); + is( enGooden("abc"), "abc", "Example 3"); + + is( enGooden("xAadBbDyCczdD"), "xyz", "upper-loeer combo"); + + done_testing; +} + +sub runBenchmark($repeat) +{ + use Benchmark qw/cmpthese/; + + cmpthese($repeat, { + label => sub { }, + }); +} -- cgit From 8f3a919b91078399c99cdf897dad9d53f1dcd944 Mon Sep 17 00:00:00 2001 From: KjetilS Date: Thu, 3 Jul 2025 17:57:56 +0200 Subject: https://theweeklychallenge.org/blog/perl-weekly-challenge-328/ --- challenge-328/kjetillll/perl/ch-1.pl | 62 ++++++++++-------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/challenge-328/kjetillll/perl/ch-1.pl b/challenge-328/kjetillll/perl/ch-1.pl index a5b617eee5..d0601270e7 100644 --- a/challenge-328/kjetillll/perl/ch-1.pl +++ b/challenge-328/kjetillll/perl/ch-1.pl @@ -1,49 +1,19 @@ + sub f { - local $_ = pop; - 1 while s{ - (.?) - \? - (.?) - } - { - $1 - . - ( grep /[^$1$2 ]/, 'a' .. 'z' )[0] - . - $2 - }ex; - $_; + local $_ = shift; + #idea: using negative lookbehind and negative lookahead replace ? one at a time with a, b or c until no more ? is replaced: + 1 while + s/ (? Date: Thu, 3 Jul 2025 21:26:39 +0200 Subject: https://theweeklychallenge.org/blog/perl-weekly-challenge-328/ --- challenge-328/kjetillll/perl/ch-1.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/challenge-328/kjetillll/perl/ch-1.pl b/challenge-328/kjetillll/perl/ch-1.pl index d0601270e7..00e456535f 100644 --- a/challenge-328/kjetillll/perl/ch-1.pl +++ b/challenge-328/kjetillll/perl/ch-1.pl @@ -9,11 +9,11 @@ sub f { $_ } -print f("a?z") eq "abz" ? "ok" : "err $f", "\n"; -print f("pe?k") eq "peak" ? "ok" : "err $f", "\n"; -print f("gra?te") eq "grabte" ? "ok" : "err $f", "\n"; -print f("a?????b") eq "ababacb" ? "ok" : "err $f", "\n"; -print f("?a?") eq "bab" ? "ok" : "err $f", "\n"; -print f("?b") eq "ab" ? "ok" : "err $f", "\n"; -print f("b???a?") eq "babcab" ? "ok" : "err $f", "\n"; -print f("?") eq "a" ? "ok" : "err $f", "\n"; +print f("a?z") eq "abz" ? "ok\n" : "err\n"; +print f("pe?k") eq "peak" ? "ok\n" : "err\n"; +print f("gra?te") eq "grabte" ? "ok\n" : "err\n"; +print f("a?????b") eq "ababacb" ? "ok\n" : "err\n"; +print f("?a?") eq "bab" ? "ok\n" : "err\n"; +print f("?b") eq "ab" ? "ok\n" : "err\n"; +print f("b???a?") eq "babcab" ? "ok\n" : "err\n"; +print f("?") eq "a" ? "ok\n" : "err\n"; -- cgit From 208bcdbf18ff1a335b8129fccf9c71b460d143f0 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Thu, 3 Jul 2025 21:50:51 +0100 Subject: - Added solutions by Bob Lied. - Added solutions by Kjetil Skotheim. - Added solutions by Luca Ferrari. --- stats/pwc-current.json | 51 ++++++++++++++++++++++++++++++- stats/pwc-language-breakdown-2019.json | 2 +- stats/pwc-language-breakdown-2020.json | 2 +- stats/pwc-language-breakdown-2021.json | 2 +- stats/pwc-language-breakdown-2022.json | 2 +- stats/pwc-language-breakdown-2023.json | 2 +- stats/pwc-language-breakdown-2024.json | 2 +- stats/pwc-language-breakdown-2025.json | 10 +++--- stats/pwc-language-breakdown-summary.json | 8 ++--- stats/pwc-leaders.json | 16 +++++----- stats/pwc-summary-1-30.json | 2 +- stats/pwc-summary-121-150.json | 2 +- stats/pwc-summary-151-180.json | 8 ++--- stats/pwc-summary-181-210.json | 2 +- stats/pwc-summary-211-240.json | 2 +- stats/pwc-summary-241-270.json | 2 +- stats/pwc-summary-271-300.json | 2 +- stats/pwc-summary-301-330.json | 2 +- stats/pwc-summary-31-60.json | 6 ++-- stats/pwc-summary-61-90.json | 2 +- stats/pwc-summary-91-120.json | 2 +- stats/pwc-summary.json | 12 ++++---- stats/pwc-yearly-language-summary.json | 10 +++--- 23 files changed, 100 insertions(+), 51 deletions(-) diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 7121028a74..96b074bce8 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -28,6 +28,16 @@ "id" : "Andrew Shitov", "name" : "Andrew Shitov" }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Bob Lied", + "name" : "Bob Lied" + }, { "data" : [ [ @@ -72,6 +82,30 @@ "id" : "Feng Chang", "name" : "Feng Chang" }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Kjetil Skotheim", + "name" : "Kjetil Skotheim" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 4 + ] + ], + "id" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, { "data" : [ [ @@ -186,6 +220,11 @@ "name" : "Andrew Shitov", "y" : 2 }, + { + "drilldown" : "Bob Lied", + "name" : "Bob Lied", + "y" : 2 + }, { "drilldown" : "Dave Jacoby", "name" : "Dave Jacoby", @@ -206,6 +245,16 @@ "name" : "Feng Chang", "y" : 2 }, + { + "drilldown" : "Kjetil Skotheim", + "name" : "Kjetil Skotheim", + "y" : 2 + }, + { + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari", + "y" : 6 + }, { "drilldown" : "Mark Anderson", "name" : "Mark Anderson", @@ -246,7 +295,7 @@ } ], "subtitle" : { - "text" : "[Champions: 13] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 16] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge - 328" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index eefebb36d1..8081d49b4e 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 6c4bb67642..c4b3865335 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index 151be86a28..8b26d8d93d 100644 --- a/stats/pwc-language-breakdown-2021.json +++ b/stats/pwc-language-breakdown-2021.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index 6b554da20b..4eb19af8de 100644 --- a/stats/pwc-language-breakdown-2022.json +++ b/stats/pwc-language-breakdown-2022.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index 932305345b..3da2cbc409 100644 --- a/stats/pwc-language-breakdown-2023.json +++ b/stats/pwc-language-breakdown-2023.json @@ -1200,7 +1200,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index 5195a938df..a62b132797 100644 --- a/stats/pwc-language-breakdown-2024.json +++ b/stats/pwc-language-breakdown-2024.json @@ -1246,7 +1246,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index 7e4240001b..d039c46a6a 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,15 +8,15 @@ "data" : [ [ "Perl", - 17 + 21 ], [ "Raku", - 10 + 12 ], [ "Blog", - 6 + 10 ] ], "id" : "328", @@ -493,7 +493,7 @@ { "drilldown" : "328", "name" : "328", - "y" : 33 + "y" : 43 }, { "drilldown" : "327", @@ -625,7 +625,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index d18c508548..8c6da6f94d 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,15 +10,15 @@ "data" : [ [ "Perl", - 16927 + 16931 ], [ "Raku", - 9421 + 9423 ], [ "Blog", - 6040 + 6044 ] ], "dataLabels" : { @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index f8362896fa..05598ca4f5 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -8,11 +8,11 @@ "data" : [ [ "Raku", - 456 + 458 ], [ "Blog", - 1153 + 1157 ] ], "id" : "Luca Ferrari", @@ -410,7 +410,7 @@ "data" : [ [ "Perl", - 358 + 360 ], [ "Blog", @@ -752,7 +752,7 @@ "data" : [ [ "Perl", - 160 + 162 ] ], "id" : "Kjetil Skotheim", @@ -797,7 +797,7 @@ { "drilldown" : "Luca Ferrari", "name" : "1: Luca Ferrari", - "y" : 3218 + "y" : 3230 }, { "drilldown" : "Roger Bell_West", @@ -922,7 +922,7 @@ { "drilldown" : "Bob Lied", "name" : "26: Bob Lied", - "y" : 800 + "y" : 804 }, { "drilldown" : "Duncan C. White", @@ -1037,7 +1037,7 @@ { "drilldown" : "Kjetil Skotheim", "name" : "49: Kjetil Skotheim", - "y" : 320 + "y" : 324 }, { "drilldown" : "Joelle Maslak", @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index bc72fba5af..0fda781bd0 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-121-150.json b/stats/pwc-summary-121-150.json index 322928ba45..2cf82008ea 100644 --- a/stats/pwc-summary-121-150.json +++ b/stats/pwc-summary-121-150.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-151-180.json b/stats/pwc-summary-151-180.json index 64ee3fc376..1a32a3e1be 100644 --- a/stats/pwc-summary-151-180.json +++ b/stats/pwc-summary-151-180.json @@ -12,7 +12,7 @@ "data" : [ 0, 16, - 160, + 162, 4, 36, 2, @@ -60,7 +60,7 @@ 0, 10, 55, - 456, + 458, 14, 4, 0, @@ -95,7 +95,7 @@ 0, 0, 30, - 1153, + 1157, 0, 0, 0, @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-181-210.json b/stats/pwc-summary-181-210.json index e4a568fc6c..d9e589a701 100644 --- a/stats/pwc-summary-181-210.json +++ b/stats/pwc-summary-181-210.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-211-240.json b/stats/pwc-summary-211-240.json index 60d2ea26c4..84fc377e7c 100644 --- a/stats/pwc-summary-211-240.json +++ b/stats/pwc-summary-211-240.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-241-270.json b/stats/pwc-summary-241-270.json index 65cf01eebb..9c0865ef08 100644 --- a/stats/pwc-summary-241-270.json +++ b/stats/pwc-summary-241-270.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-271-300.json b/stats/pwc-summary-271-300.json index 46233de1fe..55f8005e66 100644 --- a/stats/pwc-summary-271-300.json +++ b/stats/pwc-summary-271-300.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-301-330.json b/stats/pwc-summary-301-330.json index cdf797bcbe..21edd6debb 100644 --- a/stats/pwc-summary-301-330.json +++ b/stats/pwc-summary-301-330.json @@ -100,7 +100,7 @@ } ], "subtitle" : { - "text" : "[Champions: 25] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 25] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-31-60.json b/stats/pwc-summary-31-60.json index c4cedf6ebe..a4b868149a 100644 --- a/stats/pwc-summary-31-60.json +++ b/stats/pwc-summary-31-60.json @@ -23,7 +23,7 @@ 0, 0, 4, - 358, + 360, 6, 72, 2, @@ -69,8 +69,8 @@ 9, 0, 0, - 2, 17, + 2, 0, 194, 0, @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-61-90.json b/stats/pwc-summary-61-90.json index bb4bbcf5a1..6d41c923eb 100644 --- a/stats/pwc-summary-61-90.json +++ b/stats/pwc-summary-61-90.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-91-120.json b/stats/pwc-summary-91-120.json index fddea4820b..12ceaa6beb 100644 --- a/stats/pwc-summary-91-120.json +++ b/stats/pwc-summary-91-120.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json index fe1e2eb450..b37585d934 100644 --- a/stats/pwc-summary.json +++ b/stats/pwc-summary.json @@ -53,7 +53,7 @@ 0, 0, 2, - 180, + 181, 3, 36, 1, @@ -162,7 +162,7 @@ 24, 0, 9, - 81, + 82, 2, 18, 2, @@ -394,8 +394,8 @@ 6, 0, 0, - 1, 9, + 1, 0, 104, 0, @@ -505,7 +505,7 @@ 0, 5, 28, - 228, + 229, 7, 2, 0, @@ -835,7 +835,7 @@ 0, 0, 30, - 227, + 228, 0, 0, 0, @@ -1000,7 +1000,7 @@ } ], "subtitle" : { - "text" : "[Champions: 325] Last updated at 2025-07-02 22:41:24 GMT" + "text" : "[Champions: 325] Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-yearly-language-summary.json b/stats/pwc-yearly-language-summary.json index b7b287026b..9f4bcc52d8 100644 --- a/stats/pwc-yearly-language-summary.json +++ b/stats/pwc-yearly-language-summary.json @@ -8,15 +8,15 @@ "data" : [ [ "Perl", - 1160 + 1164 ], [ "Raku", - 555 + 557 ], [ "Blog", - 463 + 467 ] ], "id" : "2025", @@ -151,7 +151,7 @@ { "drilldown" : "2025", "name" : "2025", - "y" : 2178 + "y" : 2188 }, { "drilldown" : "2024", @@ -188,7 +188,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-02 22:41:24 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" }, "title" : { "text" : "The Weekly Challenge Language" -- cgit From 1d697380378cf811bb6163ebb46611f1b4688c5d Mon Sep 17 00:00:00 2001 From: Luis Mochan Date: Thu, 3 Jul 2025 16:29:30 -0600 Subject: Solve PWC328 --- challenge-328/wlmb/blog.txt | 1 + challenge-328/wlmb/perl/ch-1.pl | 24 ++++++++++++++++++++++++ challenge-328/wlmb/perl/ch-2.pl | 17 +++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 challenge-328/wlmb/blog.txt create mode 100755 challenge-328/wlmb/perl/ch-1.pl create mode 100755 challenge-328/wlmb/perl/ch-2.pl diff --git a/challenge-328/wlmb/blog.txt b/challenge-328/wlmb/blog.txt new file mode 100644 index 0000000000..5ed44b71c3 --- /dev/null +++ b/challenge-328/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2025/07/03/PWC328/ diff --git a/challenge-328/wlmb/perl/ch-1.pl b/challenge-328/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..9cffa7b2a8 --- /dev/null +++ b/challenge-328/wlmb/perl/ch-1.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +# Perl weekly challenge 328 +# Task 1: Replace all ? +# +# See https://wlmb.github.io/2025/07/03/PWC328/#task-1-replace-all-? + +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to replace ? by lowercase letters in the lowercase strings S1 S2... + so that no letter repeats. + FIN +for(@ARGV){ + say "Expected only lowercase letters and ?'s" unless /^[a-z?]+$/; + say("Expected no repeating letters in string: $_"), next if /([a-z])\1/; + my $in=$_; + 1 while s/(.?)(\?)(.?)/replace($1, $3)/e; + say "$in -> $_"; +} +sub replace($x, $z){ + my $y="a"; + ++$y while $y eq $x or $y eq $z; + "$1$y$3" +} diff --git a/challenge-328/wlmb/perl/ch-2.pl b/challenge-328/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..3c1bb357c5 --- /dev/null +++ b/challenge-328/wlmb/perl/ch-2.pl @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# Perl weekly challenge 328 +# Task 2: Good String +# +# See https://wlmb.github.io/2025/07/03/PWC328/#task-2-good-string +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to convert the strings S1 S2... into good strings + without any lowercase (uppercase) letter adjacent to the corresponding + uppercase (lowercase) letter. + FIN +for(@ARGV){ + my $in=$_; + 1 while(s/([[:alpha:]])(??{my $l=lc($1); $l eq $1? uc($1):lc($1)})//); + say"$in->$_"; +} -- cgit From 60fe9858b07ad2a1eeb703f74e7305faf183e0bd Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Fri, 4 Jul 2025 09:46:05 +0100 Subject: - Added solutions by W. Luis Mochan. --- stats/pwc-current.json | 21 ++++++++++++++++++++- stats/pwc-language-breakdown-2019.json | 2 +- stats/pwc-language-breakdown-2020.json | 2 +- stats/pwc-language-breakdown-2021.json | 2 +- stats/pwc-language-breakdown-2022.json | 2 +- stats/pwc-language-breakdown-2023.json | 2 +- stats/pwc-language-breakdown-2024.json | 2 +- stats/pwc-language-breakdown-2025.json | 8 ++++---- stats/pwc-language-breakdown-summary.json | 6 +++--- stats/pwc-leaders.json | 8 ++++---- stats/pwc-summary-1-30.json | 2 +- stats/pwc-summary-121-150.json | 2 +- stats/pwc-summary-151-180.json | 2 +- stats/pwc-summary-181-210.json | 2 +- stats/pwc-summary-211-240.json | 2 +- stats/pwc-summary-241-270.json | 2 +- stats/pwc-summary-271-300.json | 2 +- stats/pwc-summary-301-330.json | 6 +++--- stats/pwc-summary-31-60.json | 2 +- stats/pwc-summary-61-90.json | 2 +- stats/pwc-summary-91-120.json | 2 +- stats/pwc-summary.json | 6 +++--- stats/pwc-yearly-language-summary.json | 8 ++++---- 23 files changed, 57 insertions(+), 38 deletions(-) diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 96b074bce8..185d04789d 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -168,6 +168,20 @@ "id" : "Ulrich Rieke", "name" : "Ulrich Rieke" }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + }, { "data" : [ [ @@ -280,6 +294,11 @@ "name" : "Ulrich Rieke", "y" : 4 }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + }, { "drilldown" : "Wanderdoc", "name" : "Wanderdoc", @@ -295,7 +314,7 @@ } ], "subtitle" : { - "text" : "[Champions: 16] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 17] Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge - 328" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 8081d49b4e..3b599bd225 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index c4b3865335..4e2c97eff2 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index 8b26d8d93d..9c3296e164 100644 --- a/stats/pwc-language-breakdown-2021.json +++ b/stats/pwc-language-breakdown-2021.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index 4eb19af8de..1215d18a7c 100644 --- a/stats/pwc-language-breakdown-2022.json +++ b/stats/pwc-language-breakdown-2022.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index 3da2cbc409..cd3d26f51d 100644 --- a/stats/pwc-language-breakdown-2023.json +++ b/stats/pwc-language-breakdown-2023.json @@ -1200,7 +1200,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index a62b132797..f6cfeb7e89 100644 --- a/stats/pwc-language-breakdown-2024.json +++ b/stats/pwc-language-breakdown-2024.json @@ -1246,7 +1246,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index d039c46a6a..ad3903e384 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 21 + 23 ], [ "Raku", @@ -16,7 +16,7 @@ ], [ "Blog", - 10 + 11 ] ], "id" : "328", @@ -493,7 +493,7 @@ { "drilldown" : "328", "name" : "328", - "y" : 43 + "y" : 46 }, { "drilldown" : "327", @@ -625,7 +625,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 8c6da6f94d..6b433f33ae 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,7 +10,7 @@ "data" : [ [ "Perl", - 16931 + 16933 ], [ "Raku", @@ -18,7 +18,7 @@ ], [ "Blog", - 6044 + 6045 ] ], "dataLabels" : { @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 05598ca4f5..cea64a615f 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -194,7 +194,7 @@ "data" : [ [ "Perl", - 472 + 474 ], [ "Raku", @@ -202,7 +202,7 @@ ], [ "Blog", - 236 + 237 ] ], "id" : "W. Luis Mochan", @@ -852,7 +852,7 @@ { "drilldown" : "W. Luis Mochan", "name" : "12: W. Luis Mochan", - "y" : 1420 + "y" : 1426 }, { "drilldown" : "E. Choroba", @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index 0fda781bd0..76e793b893 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-121-150.json b/stats/pwc-summary-121-150.json index 2cf82008ea..d905f3eccb 100644 --- a/stats/pwc-summary-121-150.json +++ b/stats/pwc-summary-121-150.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-151-180.json b/stats/pwc-summary-151-180.json index 1a32a3e1be..3efa548b0b 100644 --- a/stats/pwc-summary-151-180.json +++ b/stats/pwc-summary-151-180.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-181-210.json b/stats/pwc-summary-181-210.json index d9e589a701..930b4fe412 100644 --- a/stats/pwc-summary-181-210.json +++ b/stats/pwc-summary-181-210.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-211-240.json b/stats/pwc-summary-211-240.json index 84fc377e7c..99b9eaa03c 100644 --- a/stats/pwc-summary-211-240.json +++ b/stats/pwc-summary-211-240.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-241-270.json b/stats/pwc-summary-241-270.json index 9c0865ef08..513f217a18 100644 --- a/stats/pwc-summary-241-270.json +++ b/stats/pwc-summary-241-270.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-271-300.json b/stats/pwc-summary-271-300.json index 55f8005e66..98f0e34f07 100644 --- a/stats/pwc-summary-271-300.json +++ b/stats/pwc-summary-271-300.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-301-330.json b/stats/pwc-summary-301-330.json index 21edd6debb..aa06961130 100644 --- a/stats/pwc-summary-301-330.json +++ b/stats/pwc-summary-301-330.json @@ -25,7 +25,7 @@ 28, 0, 4, - 472, + 474, 87, 322, 1, @@ -85,7 +85,7 @@ 0, 0, 0, - 236, + 237, 18, 2, 0, @@ -100,7 +100,7 @@ } ], "subtitle" : { - "text" : "[Champions: 25] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 25] Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-31-60.json b/stats/pwc-summary-31-60.json index a4b868149a..56571733cc 100644 --- a/stats/pwc-summary-31-60.json +++ b/stats/pwc-summary-31-60.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-61-90.json b/stats/pwc-summary-61-90.json index 6d41c923eb..e664348722 100644 --- a/stats/pwc-summary-61-90.json +++ b/stats/pwc-summary-61-90.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-91-120.json b/stats/pwc-summary-91-120.json index 12ceaa6beb..ebc0410221 100644 --- a/stats/pwc-summary-91-120.json +++ b/stats/pwc-summary-91-120.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 30] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json index b37585d934..80eb524350 100644 --- a/stats/pwc-summary.json +++ b/stats/pwc-summary.json @@ -325,7 +325,7 @@ 19, 0, 2, - 236, + 237, 44, 171, 1, @@ -985,7 +985,7 @@ 0, 0, 0, - 236, + 237, 18, 1, 0, @@ -1000,7 +1000,7 @@ } ], "subtitle" : { - "text" : "[Champions: 325] Last updated at 2025-07-03 20:50:33 GMT" + "text" : "[Champions: 325] Last updated at 2025-07-04 08:45:59 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-yearly-language-summary.json b/stats/pwc-yearly-language-summary.json index 9f4bcc52d8..3e850eb338 100644 --- a/stats/pwc-yearly-language-summary.json +++ b/stats/pwc-yearly-language-summary.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 1164 + 1166 ], [ "Raku", @@ -16,7 +16,7 @@ ], [ "Blog", - 467 + 468 ] ], "id" : "2025", @@ -151,7 +151,7 @@ { "drilldown" : "2025", "name" : "2025", - "y" : 2188 + "y" : 2191 }, { "drilldown" : "2024", @@ -188,7 +188,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-03 20:50:33 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" }, "title" : { "text" : "The Weekly Challenge Language" -- cgit From 3a060dd651d97a2b3e6f8cd2a480def82aaec3ab Mon Sep 17 00:00:00 2001 From: Scimon Date: Fri, 4 Jul 2025 10:11:44 +0100 Subject: Update during blogging --- challenge-328/simon-proctor/README | 2 +- challenge-328/simon-proctor/raku/ch-2.raku | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/challenge-328/simon-proctor/README b/challenge-328/simon-proctor/README index 6573911693..95e3ea3c89 100644 --- a/challenge-328/simon-proctor/README +++ b/challenge-328/simon-proctor/README @@ -1,3 +1,3 @@ Solution by Simon Proctor -Blog at : https://khanate.co.uk/weekly/326.html \ No newline at end of file +Blog at : https://khanate.co.uk/weekly/ \ No newline at end of file diff --git a/challenge-328/simon-proctor/raku/ch-2.raku b/challenge-328/simon-proctor/raku/ch-2.raku index fb882ccac5..b77047272b 100755 --- a/challenge-328/simon-proctor/raku/ch-2.raku +++ b/challenge-328/simon-proctor/raku/ch-2.raku @@ -2,7 +2,7 @@ subset ValidInput of Str where * ~~ /^ <[a..z A..Z]> + $/; -multi sub MAIN(1) { +multi sub MAIN(1) is hidden-from-USAGE { use Test; ok "WeEekly" ~~ ValidInput, 'Valid Input works'; ok "1234" !~~ ValidInput, 'Valid input fails for invalid value'; -- cgit From b23df451821993e60fe094025fbfba4b29e61d06 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Fri, 4 Jul 2025 11:20:32 +0200 Subject: Solution to task 1 --- challenge-328/jo-37/perl/ch-1.pl | 101 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 challenge-328/jo-37/perl/ch-1.pl diff --git a/challenge-328/jo-37/perl/ch-1.pl b/challenge-328/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..798787cf22 --- /dev/null +++ b/challenge-328/jo-37/perl/ch-1.pl @@ -0,0 +1,101 @@ +#!/usr/bin/perl + +use v5.26; +use Test2::V0 -no_srand; +use Test2::Tools::Subtest 'subtest_streamed'; +use Getopt::Long; +use experimental qw(signatures vlb); + + +### Options and Arguments + +my ($tests, $examples, $verbose); +GetOptions( + 'examples!' => \$examples, + 'tests!' => \$tests, + 'verbose!' => \$verbose, +) or usage(); + +run_tests($examples, $tests); # tests do not return + +usage() unless @ARGV == 1; + +sub usage { + die <<~EOS; + $0 - replace all ? + + usage: $0 [-examples] [-tests] [STR] + + -examples + run the examples from the challenge + + -tests + run some tests + + STR + a string + + EOS +} + + +### Input and Output + +say replace_all(shift); + + +### Implementation +# +# For details see: +# https://github.sommrey.de/the-bears-den/2025/07/04/ch-328.html#task-1 + +sub rc { + (\my %c)->@{'a' .. 'z'} = (); + delete @c{@_}; + + scalar each %c; +} + +sub replace_all ($str) { + 1 while $str =~ s/(?<=([^?]?))\?(?=([^?]?))/rc($1, $2)/e; + + $str; +} + + +### Examples and Tests + +sub run_tests ($examples, $tests) { + return unless $examples || $tests; + + state sub run_example ($str, $name) { + my $result = replace_all($str); + my $pattern = $str =~ s/\?/./gr; + subtest("$name: $str -> $result" => sub { + plan 2; + like $result, qr/$pattern/, 'match characters'; + unlike $result, qr/(.)\1/, 'no repeated characters'; + }); + } + + plan 2; + + $examples ? subtest_streamed(examples => sub { + my @examples = ( + ['a?z', 'example 1'], + ['pe?k', 'example 2'], + ['gra?te', 'example 3'], + ); + plan scalar @examples; + for (@examples) { + run_example @$_; + } + }) : pass 'skip examples'; + + $tests ? subtest_streamed(tests => sub { + plan 1; + run_example('a???b', 'adjacent question marks'); + }) : pass 'skip tests'; + + exit; +} -- cgit From 6c65435a654e667e1c153e12dc83b5a44b4ecc89 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Fri, 4 Jul 2025 11:21:15 +0200 Subject: Solution to task 2 --- challenge-328/jo-37/perl/ch-2.pl | 110 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 challenge-328/jo-37/perl/ch-2.pl diff --git a/challenge-328/jo-37/perl/ch-2.pl b/challenge-328/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..213d08af72 --- /dev/null +++ b/challenge-328/jo-37/perl/ch-2.pl @@ -0,0 +1,110 @@ +#!/usr/bin/perl + +use v5.26; +use Test2::V0 -no_srand; +use Test2::Tools::Subtest 'subtest_streamed'; +use Getopt::Long; +use experimental 'signatures'; + +use String::Compile::Tr; + + +### Options and Arguments + +my ($tests, $examples, $remove_pairs, $make_good, $verbose); +GetOptions( + 'examples!' => \$examples, + 'tests!' => \$tests, + 'verbose!' => \$verbose, + '1!' => \$remove_pairs, + '2!' => \$make_good, +) or usage(); +$remove_pairs = 1 unless $make_good; + +run_tests($examples, $tests); # tests do not return + +usage() unless @ARGV == 1; + +sub usage { + die <<~EOS; + $0 - good string + + usage: $0 [-examples] [-tests] [STR] + + -examples + run the examples from the challenge + + -tests + run some tests + + STR + a string + + EOS +} + + +### Input and Output + +say "remove pairs: '@{[remove_pairs(@ARGV)]}'" if $remove_pairs; +say "make good: '@{[make_good(@ARGV)]}'" if $make_good; + + +### Implementation +# +# For details see: +# https://github.sommrey.de/the-bears-den/2025/07/04/ch-328.html#task-2 + + +sub remove_pairs ($str) { + 1 while $str =~ s/(\p{Lu})(??{lc $1})|(\p{Ll})(??{uc $2})//; + $str; +} + +sub make_good { + shift =~ s/(\p{LC})\1+/ + trgen(2 * trgen(lc($1))->($&) < length($&) ? lc($1) : uc($1), + '', 'dr')->($&); + /iegr; +} + + +### Examples and Tests + +sub run_tests ($examples, $tests) { + return unless $examples || $tests; + + state sub run_example ($str, $removed, $good, $name) { + subtest(qq{$name: "$str"} => sub { + plan 2; + my $result1 = remove_pairs($str); + is $result1, $removed, + qq{remove pairs -> "$removed"}; + my $result2 = make_good($str); + is $result2, $good, + qq{make good -> "$good"}; + }); + } + + plan 2; + + $examples ? subtest_streamed(examples => sub { + my @examples = ( + ['WeEeekly', 'Weekly', 'Weeekly', 'example 1'], + ['abBAdD', '', 'abAd', 'example 2'], + ['abc', 'abc', 'abc', 'example 3'], + ); + plan scalar @examples; + for (@examples) { + run_example @$_; + } + }) : pass 'skip examples'; + + $tests ? subtest_streamed(tests => sub { + plan 2; + run_example('WeEeEkly', 'Wkly', 'Weekly', 'even repetitions'); + run_example('WeEeEekly', 'Wekly', 'Weeekly', 'odd repetitions'); + }) : pass 'skip tests'; + + exit; +} -- cgit From 4af1b74a12226cda1da1ecf7b2822bc142e9f230 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Fri, 4 Jul 2025 11:21:39 +0200 Subject: Blog for challenge 328 --- challenge-328/jo-37/blog.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-328/jo-37/blog.txt diff --git a/challenge-328/jo-37/blog.txt b/challenge-328/jo-37/blog.txt new file mode 100644 index 0000000000..c052b935b4 --- /dev/null +++ b/challenge-328/jo-37/blog.txt @@ -0,0 +1 @@ +https://github.sommrey.de/the-bears-den/2025/07/04/ch-328.html -- cgit From 5ea606f19ac8c1dfa89419f67b0f0989fd0fad79 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Fri, 4 Jul 2025 10:57:40 +0100 Subject: - Added solutions by Jorg Sommrey. - Added solutions by Simon Proctor. --- challenge-328/simon-proctor/blog.txt | 1 + stats/pwc-current.json | 27 +++++++++++++-- stats/pwc-language-breakdown-2019.json | 2 +- stats/pwc-language-breakdown-2020.json | 2 +- stats/pwc-language-breakdown-2021.json | 2 +- stats/pwc-language-breakdown-2022.json | 2 +- stats/pwc-language-breakdown-2023.json | 2 +- stats/pwc-language-breakdown-2024.json | 2 +- stats/pwc-language-breakdown-2025.json | 8 ++--- stats/pwc-language-breakdown-summary.json | 6 ++-- stats/pwc-leaders.json | 56 +++++++++++++++---------------- stats/pwc-summary-1-30.json | 2 +- stats/pwc-summary-121-150.json | 6 ++-- stats/pwc-summary-151-180.json | 2 +- stats/pwc-summary-181-210.json | 2 +- stats/pwc-summary-211-240.json | 2 +- stats/pwc-summary-241-270.json | 2 +- stats/pwc-summary-271-300.json | 4 +-- stats/pwc-summary-301-330.json | 2 +- stats/pwc-summary-31-60.json | 4 +-- stats/pwc-summary-61-90.json | 2 +- stats/pwc-summary-91-120.json | 2 +- stats/pwc-summary.json | 8 ++--- stats/pwc-yearly-language-summary.json | 8 ++--- 24 files changed, 90 insertions(+), 66 deletions(-) create mode 100644 challenge-328/simon-proctor/blog.txt diff --git a/challenge-328/simon-proctor/blog.txt b/challenge-328/simon-proctor/blog.txt new file mode 100644 index 0000000000..ffa0a565b4 --- /dev/null +++ b/challenge-328/simon-proctor/blog.txt @@ -0,0 +1 @@ +https://khanate.co.uk/weekly/328.html diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 185d04789d..36f138dcd4 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -82,6 +82,20 @@ "id" : "Feng Chang", "name" : "Feng Chang" }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, { "data" : [ [ @@ -135,6 +149,10 @@ [ "Raku", 2 + ], + [ + "Blog", + 1 ] ], "id" : "Simon Proctor", @@ -259,6 +277,11 @@ "name" : "Feng Chang", "y" : 2 }, + { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 3 + }, { "drilldown" : "Kjetil Skotheim", "name" : "Kjetil Skotheim", @@ -282,7 +305,7 @@ { "drilldown" : "Simon Proctor", "name" : "Simon Proctor", - "y" : 2 + "y" : 3 }, { "drilldown" : "Thomas Kohler", @@ -314,7 +337,7 @@ } ], "subtitle" : { - "text" : "[Champions: 17] Last updated at 2025-07-04 08:46:00 GMT" + "text" : "[Champions: 18] Last updated at 2025-07-04 09:57:29 GMT" }, "title" : { "text" : "The Weekly Challenge - 328" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 3b599bd225..90afda4d75 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 09:57:29 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 4e2c97eff2..c9fc13d9dc 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 08:46:00 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-07-04 09:57:29 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc