diff options
| author | Luis Mochan <mochan@fis.unam.mx> | 2025-10-19 13:32:33 -0600 |
|---|---|---|
| committer | Luis Mochan <mochan@fis.unam.mx> | 2025-10-19 13:32:33 -0600 |
| commit | 09e71f9c374582a9bf0c5596664bd9ddbad7b328 (patch) | |
| tree | 022d9747c47c3a3f0f0c91119373027728489a83 | |
| parent | d8365bb892e2d1188a9cd24270aa455cffa26994 (diff) | |
| download | perlweeklychallenge-club-09e71f9c374582a9bf0c5596664bd9ddbad7b328.tar.gz perlweeklychallenge-club-09e71f9c374582a9bf0c5596664bd9ddbad7b328.tar.bz2 perlweeklychallenge-club-09e71f9c374582a9bf0c5596664bd9ddbad7b328.zip | |
Merge with upstream
35 files changed, 514 insertions, 720 deletions
diff --git a/challenge-287/ppentchev/rust/Cargo.lock b/challenge-287/ppentchev/rust/Cargo.lock index 2edaa0c161..e6a20b3142 100644 --- a/challenge-287/ppentchev/rust/Cargo.lock +++ b/challenge-287/ppentchev/rust/Cargo.lock @@ -188,12 +188,11 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" dependencies = [ - "overload", - "winapi", + "windows-sys", ] [[package]] @@ -203,12 +202,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] name = "perl-weekly-challenge-287" version = "0.1.0" dependencies = [ @@ -424,9 +417,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -445,9 +438,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ "nu-ansi-term", "sharded-slab", @@ -470,26 +463,77 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" diff --git a/challenge-287/ppentchev/rust/Cargo.toml b/challenge-287/ppentchev/rust/Cargo.toml index b6b2a52377..fabe2a8876 100644 --- a/challenge-287/ppentchev/rust/Cargo.toml +++ b/challenge-287/ppentchev/rust/Cargo.toml @@ -18,7 +18,7 @@ keywords = ["perl-weekly-challenge"] anyhow = "1" nom = "7.1.2" tracing = "0.1.40" -tracing-subscriber = "0.3.18" +tracing-subscriber = "0.3.20" [dev-dependencies] rstest = "0.22" diff --git a/challenge-342/bob-lied/README.md b/challenge-342/bob-lied/README.md index e3e8ac2801..09c03618a3 100644 --- a/challenge-342/bob-lied/README.md +++ b/challenge-342/bob-lied/README.md @@ -1,5 +1,6 @@ -# Solutions to weekly challenge 341 by Bob Lied +# Solutions to weekly challenge 342 by Bob Lied -## [PWC](https://perlweeklychallenge.org/blog/perl-weekly-challenge-341/) -## [GitHub](https://github.com/boblied/perlweeklychallenge-club/tree/master/challenge-341/bob-lied) -[Blog](https://dev.to/boblied/) +## [PWC](https://perlweeklychallenge.org/blog/perl-weekly-challenge-342/) +## [GitHub](https://github.com/boblied/perlweeklychallenge-club/tree/master/challenge-342/bob-lied) +[Blog Task 1](https://dev.to/boblied/pwc-342-balance-4eh4) +[Blog Task 2](https://dev.to/boblied/pwc-342-max-score-all-your-0s-and-1s-are-belong-to-us-4bn7) diff --git a/challenge-342/matthias-muth/README.md b/challenge-342/matthias-muth/README.md index 428c554463..0da0bf4f43 100644 --- a/challenge-342/matthias-muth/README.md +++ b/challenge-342/matthias-muth/README.md @@ -1,167 +1,5 @@ -# (Pre-)Fix what is Broken - -**Challenge 341 solutions in Perl by Matthias Muth** - -## Task 1: Broken Keyboard - -> You are given a string containing English letters only and also you are given broken keys.<br/> -> Write a script to return the total words in the given sentence can be typed completely. -> -> **Example 1** -> -> ```text -> Input: $str = 'Hello World', @keys = ('d') -> Output: 1 -> -> With broken key 'd', we can only type the word 'Hello'. -> ``` -> -> **Example 2** -> -> ```text -> Input: $str = 'apple banana cherry', @keys = ('a', 'e') -> Output: 0 -> ``` -> -> **Example 3** -> -> ```text -> Input: $str = 'Coding is fun', @keys = () -> Output: 3 -> -> No keys broken. -> ``` -> -> **Example 4** -> -> ```text -> Input: $str = 'The Weekly Challenge', @keys = ('a','b') -> Output: 3 -> ``` -> -> **Example 5** -> -> ```text -> Input: $str = 'Perl and Python', @keys = ('p') -> Output: 1 -> ``` - -Perl's regular expressions help to find a concise solution for this task.<br/>But the main goal for me this time isn't shortness, it's readability. - -This could have been my short solution: - -```perl -sub broken_keyboard_short_and_ugly( $str, $keys ) { - scalar grep ! $keys->@* || ! /[$keys->@*]/i, split " ", $str; -} -``` - -(Assuming `use v5.36` or whatever you prefer for having `strict`, `warnings`, and `feature signatures`.) - -Don't worry, there's no need to dive into it to see what it does. I will explain later for those who are curious. - -Here is my 'real' solution.<br/> -This one is much clearer, I hope: - -```perl -use v5.36; - -sub broken_keyboard( $str, $keys ) { - my @words = split " ", $str; - return scalar @words - if ! $keys->@*; - my $keys_concat = join "", $keys->@*; - return scalar grep ! /[$keys_concat]/i, @words; -} -``` - -The concept is the same, only that this code can almost be read as its own description in English: - -* - Split up the input string into words, using any amount of whitespace as separator<br/>(the `" "` special case for the `split` separator does that perfectly):<br/> - ` my @words = split " ", $str;` -* Return the full number of words if there are no broken keys.<br/> - ` return scalar @words`<br/>` if ! $keys->@*;` -* Build a string with the concatenated broken key characters<br/>(we will see in the next step what that will be used for):<br/> - ` my $keys_concat = join "", $keys->@*;` -* Return the count of words that do not(!) match a regular expression with a bracketed character class containing all broken keys, ignoring upper or lower case.<br/> - ` return scalar grep ! /[$keys_concat]/i, @words;`<br/> - (`grep` in scalar context returns the number of hits instead of the hits themselves.) - -There are chances that even I will understand what I wrote when I stumble over this code in a year or so... - -But just for the curious, here is what the 'short' version does.<br/>Basically the same thing just mapped into one single statement, but with a fews pitfalls: - -* For keeping the code short, the `grep` condition contains both cases of having broken keys or not.<br/>It is assumed that any word is a hit if there are no keys (`! $keys->@*`) or -- if there are -- the word does not match the regular expression containing the character class with the list of broken keys.<br/>Clearly, there is a runtime punishment for this. The check whether we have any broken keys is repeated for every word. -* Watch out: In the regular expression, the *array* is interpolated into the character class (not a string, as in the other solution).<br/>This results in all array elements being put in, separated by space characters. Similar to using `"$keys->@*"` in double quoted strings.<br/>But that means that our character class also contains space characters. So actually we are not only looking for broken keys in the words, but also for space characters!<br/> - Good that we know there cannot be any... - -So to understand the code fully, the reader also has to understand these specialties. Any changes to the code can be surprising... - -This is why I didn't use my shortest solution for this task.<br/>I hope you agree. - -## Task 2: Reverse Prefix - -> You are given a string, \$str and a character in the given string, \$char.<br/> -> Write a script to reverse the prefix upto the first occurrence of the given \$char in the given string \$str and return the new string. -> -> **Example 1** -> -> ```text -> Input: $str = "programming", $char = "g" -> Output: "gorpmming" -> -> Reverse of prefix "prog" is "gorp". -> ``` -> -> **Example 2** -> -> ```text -> Input: $str = "hello", $char = "h" -> Output: "hello" -> ``` -> -> **Example 3** -> -> ```text -> Input: $str = "abcdefghij", $char = "h" -> Output: "hgfedcbaj" -> ``` -> -> **Example 4** -> -> ```text -> Input: $str = "reverse", $char = "s" -> Output: "srevere" -> ``` -> -> **Example 5** -> -> ```text -> Input: $str = "perl", $char = "r" -> Output: "repl" -> ``` - -Now this is the task where I fully promote a short solution!<br/> -A single regular expression substitution is all that is needed: - -```perl -use v5.36; - -sub reverse_prefix( $str, $char ) { - return $str =~ s<^.*?$char>{ reverse $& }er; -} -``` - -Explanation? - -Everything from the beginning of the string up to and including the first `$char` character is matched:<br/>` /^.*?$char/`<br/>The 'everything' match is 'non-greedy' (`.*?`), so that it stops when the first `$char` is found. - -The replacement for the prefix is generated with `reverse $&`. That's why the substitution part is an evaluated expression (code), using the `/e` flag.<br/>It's a habit of mine to put the code part into curly brackets when I use the `/e` flag, to make it more visible.<br/> -I then use a pair of angle brackets for the first part. - -The `/r` flag returns the resulting string (instead of the number of matches found).<br/>That's the subroutine's return value, and that's all. - - This is Perl. Not everything short is bad! +**Challenge 342 solutions in Perl by Matthias Muth** +<br/> +(sorry, no blog post this time...) **Thank you for the challenge!** diff --git a/challenge-342/packy-anderson/README.md b/challenge-342/packy-anderson/README.md index 704729b966..29039bec47 100644 --- a/challenge-342/packy-anderson/README.md +++ b/challenge-342/packy-anderson/README.md @@ -23,4 +23,4 @@ ## Blog Post -[Perl Weekly Challenge: Something just BROKE](https://packy.dardan.com/b/bw) +[Perl Weekly Challenge: Balanced Adagio for Strings](https://packy.dardan.com/b/cQ) diff --git a/challenge-342/ryan-thompson/README.md b/challenge-342/ryan-thompson/README.md index 770aebaa99..ec7aeb0f5f 100644 --- a/challenge-342/ryan-thompson/README.md +++ b/challenge-342/ryan-thompson/README.md @@ -1,18 +1,18 @@ # Ryan Thompson -## Week 341 Solutions +## Week 342 Solutions -### Task 1 › Broken Keyboard +### Task 1 › Balanced Strings * [Perl](perl/ch-1.pl) -### Task 2 › Reverse Prefix +### Task 2 › Max Score * [Perl](perl/ch-2.pl) ## Blog - * [Brken Keybard and Reverse Prefix](https://ry.ca/2025/10/brken-keybards-reverse-prefixes/) + * [Perfectly Balanced and Pointlessly Optimized](https://ry.ca/2025/10/pwc-342-balanced-optimized/) ## Tests diff --git a/challenge-342/sgreen/README.md b/challenge-342/sgreen/README.md index 89934768da..33d3a4920d 100644 --- a/challenge-342/sgreen/README.md +++ b/challenge-342/sgreen/README.md @@ -1,3 +1,3 @@ -# The Weekly Challenge 341 +# The Weekly Challenge 342 -Blog: [Reversing my broken keys](https://dev.to/simongreennet/weekly-challenge-reversing-my-broken-keys-313l) +Blog: [Balancing the Score](https://dev.to/simongreennet/weekly-challenge-balancing-the-score-38kd) diff --git a/stats/pwc-challenge-203.json b/stats/pwc-challenge-203.json index 6f2f14e9f3..2dc62bf08c 100644 --- a/stats/pwc-challenge-203.json +++ b/stats/pwc-challenge-203.json @@ -183,6 +183,10 @@ [ "Raku", 2 + ], + [ + "Blog", + 1 ] ], "id" : "Jaldhar H. Vyas", @@ -556,7 +560,7 @@ { "drilldown" : "Jaldhar H. Vyas", "name" : "Jaldhar H. Vyas", - "y" : 4 + "y" : 5 }, { "drilldown" : "James Smith", @@ -673,7 +677,7 @@ } ], "subtitle" : { - "text" : "[Champions: 38] Last updated at 2025-10-05 18:44:26 GMT" + "text" : "[Champions: 38] Last updated at 2025-10-07 10:01:30 GMT" }, "title" : { "text" : "The Weekly Challenge - 203" diff --git a/stats/pwc-challenge-210.json b/stats/pwc-challenge-210.json index b77319233b..3a7325a7e9 100644 --- a/stats/pwc-challenge-210.json +++ b/stats/pwc-challenge-210.json @@ -153,6 +153,10 @@ [ "Raku", 2 + ], + [ + "Blog", + 1 ] ], "id" : "Jaldhar H. Vyas", @@ -539,7 +543,7 @@ { "drilldown" : "Jaldhar H. Vyas", "name" : "Jaldhar H. Vyas", - "y" : 4 + "y" : 5 }, { "drilldown" : "James Smith", @@ -666,7 +670,7 @@ } ], "subtitle" : { - "text" : "[Champions: 37] Last updated at 2025-10-05 18:44:26 GMT" + "text" : "[Champions: 37] Last updated at 2025-10-07 10:01:30 GMT" }, "title" : { "text" : "The Weekly Challenge - 210" diff --git a/stats/pwc-challenge-259.json b/stats/pwc-challenge-259.json index 55055b3204..1d39223fa4 100644 --- a/stats/pwc-challenge-259.json +++ b/stats/pwc-challenge-259.json @@ -143,6 +143,10 @@ [ "Raku", 2 + ], + [ + "Blog", + 1 ] ], "id" : "Jaldhar H. Vyas", @@ -466,7 +470,7 @@ { "drilldown" : "Jaldhar H. Vyas", "name" : "Jaldhar H. Vyas", - "y" : 4 + "y" : 5 }, { "drilldown" : "Jan Krnavek", @@ -568,7 +572,7 @@ } ], "subtitle" : { - "text" : "[Champions: 31] Last updated at 2025-10-03 19:04:10 GMT" + "text" : "[Champions: 31] Last updated at 2025-10-07 10:01:30 GMT" }, "title" : { "text" : "The Weekly Challenge - 259" diff --git a/stats/pwc-challenge-339.json b/stats/pwc-challenge-339.json index 8a71d71fd7..2fde0c5d8b 100644 --- a/stats/pwc-challenge-339.json +++ b/stats/pwc-challenge-339.json @@ -147,6 +147,20 @@ [ "Perl", 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "data" : [ + [ + "Perl", + 2 ] ], "id" : "Lubos Kolouch", @@ -464,6 +478,11 @@ "y" : 1 }, { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 3 + }, + { "drilldown" : "Lubos Kolouch", "name" : "Lubos Kolouch", "y" : 2 @@ -568,7 +587,7 @@ } ], "subtitle" : { - "text" : "[Champions: 31] Last updated at 2025-10-01 08:46:45 GMT" + "text" : "[Champions: 32] Last updated at 2025-10-19 01:36:35 GMT" }, "title" : { "text" : "The Weekly Challenge - 339" diff --git a/stats/pwc-challenge-340.json b/stats/pwc-challenge-340.json index e2a8d084b9..744802d3ee 100644 --- a/stats/pwc-challenge-340.json +++ b/stats/pwc-challenge-340.json @@ -149,6 +149,20 @@ [ "Perl", 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "data" : [ + [ + "Perl", + 2 ] ], "id" : "Kjetil Skotheim", @@ -477,6 +491,11 @@ "y" : 2 }, { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 3 + }, + { "drilldown" : "Kjetil Skotheim", "name" : "Kjetil Skotheim", "y" : 2 @@ -586,7 +605,7 @@ } ], "subtitle" : { - "text" : "[Champions: 33] Last updated at 2025-09-29 11:43:19 GMT" + "text" : "[Champions: 34] Last updated at 2025-10-19 01:36:35 GMT" }, "title" : { "text" : "The Weekly Challenge - 340" diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 6502ab7e7f..435405f42f 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -32,7 +32,7 @@ "data" : [ [ "Raku", - 2 + 1 ] ], "id" : "Andrew Shitov", @@ -42,25 +42,21 @@ "data" : [ [ "Raku", - 2 - ], - [ - "Blog", 1 ] ], - "id" : "Arne Sommer", - "name" : "Arne Sommer" + "id" : "Asher Harvey-Smith", + "name" : "Asher Harvey-Smith" }, { "data" : [ [ "Perl", - 2 + 1 ], [ "Raku", - 2 + 1 ] ], "id" : "Athanasius", @@ -69,16 +65,6 @@ { "data" : [ [ - "Raku", - 1 - ] - ], - "id" : "BarrOff", - "name" : "BarrOff" - }, - { - "data" : [ - [ "Perl", 2 ] @@ -123,36 +109,12 @@ 2 ], [ - "Raku", - 2 - ], - [ "Blog", 1 ] ], - "id" : "Jaldhar H. Vyas", - "name" : "Jaldhar H. Vyas" - }, - { - "data" : [ - [ - "Raku", - 2 - ] - ], - "id" : "Jan Krnavek", - "name" : "Jan Krnavek" - }, - { - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "Kjetil Skotheim", - "name" : "Kjetil Skotheim" + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" }, { "data" : [ @@ -169,30 +131,6 @@ [ "Raku", 2 - ], - [ - "Blog", - 10 - ] - ], - "id" : "Luca Ferrari", - "name" : "Luca Ferrari" - }, - { - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "Mariano Spadaccini", - "name" : "Mariano Spadaccini" - }, - { - "data" : [ - [ - "Raku", - 2 ] ], "id" : "Mark Anderson", @@ -227,6 +165,10 @@ [ "Perl", 1 + ], + [ + "Raku", + 1 ] ], "id" : "Mohammad Sajid Anwar", @@ -239,16 +181,6 @@ 2 ] ], - "id" : "Nicolas Mendoza", - "name" : "Nicolas Mendoza" - }, - { - "data" : [ - [ - "Perl", - 2 - ] - ], "id" : "Niels van Dijke", "name" : "Niels van Dijke" }, @@ -311,16 +243,6 @@ { "data" : [ [ - "Raku", - 2 - ] - ], - "id" : "Robert Ransbottom", - "name" : "Robert Ransbottom" - }, - { - "data" : [ - [ "Perl", |
