TABLE OF CONTENTS
1. HEADLINES
2. SPONSOR
3. RECAP
4. PERL REVIEW
5. RAKU REVIEW
6. CHART
7. NEW MEMBERS
8. GUESTS
9. TASK #1: Good Substrings
10. TASK #2: Shuffle Pairs
HEADLINES
Welcome to the Week #350 of The Weekly Challenge.
Welcome aboard, Alexandre Ros, an expert Uiua hacker. Surprisingly, Uiua becoming hot favourite these days. We have had three recently joined guest contributors, all choosing Uiua. Thank you, Alexandre, for sharing the first contributions in Uiua.
Last saturday, I had the opportunity to attend the London Perl & Raku Workshop 2025. To my surprise, I met Andrew Shitov and Arne Sommer, two Raku geniuses. I presented the talk Design Patterns in Modern Perl. I used the platform to launch my first book on the same subject.
At the event, I met Ruweda Ahmed, a newbie in Perl who is interested in playing with the weekly challenge. In fact, she was introduced to the weekly challenge by a fellow senior member of the community at the event. I have formally invited her to join Team PWC.
The guest contributions never disappoint me, honestly. Sometimes, it is too much to consume, I am overwhelmed. Just looking at the past three weeks contributions, 67, 70 and 83. The Week #349 became the best week of the year as far as guest contributions is concerned.
Here, we have best performing week per year.
+------+-------------+---------------+
| Year | Week Number | Contributions |
+------+-------------+---------------+
| 2025 | 349 | 83 |
| 2024 | 250 | 86 |
| 2023 | 240 | 89 |
| 2022 | 153 | 120 |
| 2021 | 145 | 94 |
| 2020 | 89 | 71 |
| 2019 | 1 | 72 |
+------+-------------+---------------+
Having seen the guest contributions stat, let’s check out the best week per year for regular contributions. The Week #1 still holding the number one spot.
+------+-------------+---------------+
| Year | Week Number | Contributions |
+------+-------------+---------------+
| 2025 | 341 | 107 |
| 2024 | 258,273 | 127 |
| 2023 | 231 | 141 |
| 2022 | 192 | 129 |
| 2021 | 119 | 125 |
| 2020 | 83 | 127 |
| 2019 | 1 | 166 |
+------+-------------+---------------+
Below is my contributions to the Task #1 of Week #349.
Perl: source code
sub power_string {
my ($s) = @_;
return 0 unless length $s;
my $max = 1;
my $count = 1;
for my $i (1 .. length($s)-1) {
if (substr($s,$i,1) eq substr($s,$i-1,1)) {
$count++;
} else {
$max = $count if $count > $max;
$count = 1;
}
}
$max = $count if $count > $max;
return $max;
}
Raku: source code
sub power_string(Str $s) {
return 0 if $s.chars == 0;
my $max = 1;
my $count = 1;
for 1 ..^ $s.chars -> $i {
if $s.substr($i,1) eq $s.substr($i-1,1) {
$count++;
} else {
$max = $count if $count > $max;
$count = 1;
}
}
$max = $count if $count > $max;
return $max;
}
Python: source code
def power_string(s: str) -> int:
if len(s) == 0:
return 0
max_len = 1
count = 1
for i in range(1, len(s)):
if s[i] == s[i-1]:
count += 1
else:
if count > max_len:
max_len = count
count = 1
if count > max_len:
max_len = count
return max_len
Thank you Team PWC, once again.
Happy Hacking!!
Advent Calendar 2025
Today marked the start of Advent Calendar 2025. Looking forward to more such magical contributions in coming days.
Day 1: 3-digits Even/Delete and Earn by Ali Moradi.
Last 5 weeks mainstream contribution stats. Thank you Team PWC for your support and encouragements.
Week |
Perl |
Raku |
Blog |
345 |
49 | 22 | 15 |
346 |
50 | 18 | 15 |
347 |
47 | 21 | 24 |
348 |
47 | 23 | 26 |
349 |
49 | 23 | 26 |
Last 5 weeks guest contribution stats. Thank you each and every guest contributors for your time and efforts.
Week |
Guests |
Contributions |
Languages |
345 |
17 | 57 | 18 |
346 |
15 | 51 | 17 |
347 |
16 | 67 | 21 |
348 |
16 | 70 | 23 |
349 |
18 | 83 | 24 |
TOP 10 Guest Languages
Do you see your favourite language in the Top #10? If not then why not contribute regularly and make it to the top.
1. Python (3792)
2. Rust (1054)
3. Ruby (850)
4. Haskell (837)
5. Lua (800)
6. C++ (670)
7. JavaScript (602)
8. C (596)
9. Go (590)
10. BQN (487)
Blogs with Creative Title
1. Power Pointing by Arne Sommer.
2. More complex than it has to be by Bob Lied.
3. Meeting Strings by Jorg Sommrey.
4. moving and grepping by Luca Ferrari.
5. Power Meets Points by Matthias Muth.
6. The Power of String by Packy Anderson.
7. Powering to the origin by Peter Campbell Smith.
8. Power Meeting by Roger Bell_West.
9. Power Meeting by Simon Green.
GitHub Repository Stats
1. Commits: 46,516 (+120)
2. Pull Requests: 13,073 (+39)
3. Contributors: 266 (+1)
4. Fork: 342 (+3)
5. Stars: 202 (+2)
SPONSOR
With start of Week #268, we have a new sponsor Lance Wicks until the end of year 2025. Having said we are looking for more sponsors so that we can go back to weekly winner. If anyone interested please get in touch with us at perlweeklychallenge@yahoo.com. Thanks for your support in advance.
RECAP
Quick recap of The Weekly Challenge - 349 by Mohammad Sajid Anwar.
PERL REVIEW
If you missed any past reviews then please check out the collection.
RAKU REVIEW
If you missed any past reviews then please check out the collection.
CHART
Please take a look at the charts showing interesting data.
I would like to THANK every member of the team for their valuable suggestions. Please do share your experience with us.
NEW MEMBERS
Alexandre Ros, an expert Uiua hacker joined Team PWC.
Please find out How to contribute?, if you have any doubts.
Please try the excellent tool EZPWC created by respected member Saif Ahmed of Team PWC.
GUESTS
Please check out the guest contributions for the Week #349.
Please find past solutions by respected guests. Please share your creative solutions in other languages.
Task 1: Good Substrings
Submitted by: Mohammad Sajid Anwar
You are given a string.
Write a script to return the number of good substrings of length three in the given string.
A string is good if there are no repeated characters.
Example 1
Input: $str = "abcaefg"
Output: 5
Good substrings of length 3: abc, bca, cae, aef and efg
Example 2
Input: $str = "xyzzabc"
Output: 3
Good substrings of length 3: "xyz", "zab" and "abc"
Example 3
Input: $str = "aababc"
Output: 1
Good substrings of length 3: "abc"
Example 4
Input: $str = "qwerty"
Output: 4
Good substrings of length 3: "qwe", "wer", "ert" and "rty"
Example 5
Input: $str = "zzzaaa"
Output: 0
Task 2: Shuffle Pairs
Submitted by: E. Choroba
If two integers A <= B have the same digits but in different orders, we say that they belong to the same shuffle pair if and only if there is an integer k such that A = B * k. k is called the witness of the pair.
For example, 1359 and 9513 belong to the same shuffle pair, because 1359 * 7 = 9513.
Interestingly, some integers belong to several different shuffle pairs. For example, 123876 forms one shuffle pair with 371628, and another with 867132, as 123876 * 3 = 371628, and 123876 * 7 = 867132.
Write a function that for a given $from, $to, and $count returns the number of integers $i in the range $from <= $i <= $to that belong to at least $count different shuffle pairs.
PS: Inspired by a conversation between Mark Dominus and Simon Tatham at Mastodon.
Example 1
Input: $from = 1, $to = 1000, $count = 1
Output: 0
There are no shuffle pairs with elements less than 1000.
Example 2
Input: $from = 1500, $to = 2500, $count = 1
Output: 3
There are 3 integers between 1500 and 2500 that belong to shuffle pairs.
1782, the other element is 7128 (witness 4)
2178, the other element is 8712 (witness 4)
2475, the other element is 7425 (witness 3)
Example 3
Input: $from = 1_000_000, $to = 1_500_000, $count = 5
Output: 2
There are 2 integers in the given range that belong to 5 different shuffle pairs.
1428570 pairs with 2857140, 4285710, 5714280, 7142850, and 8571420
1429857 pairs with 2859714, 4289571, 5719428, 7149285, and 8579142
The witnesses are 2, 3, 4, 5, and 6 for both the integers.
Example 4
Input: $from = 13_427_000, $to = 14_100_000, $count = 2
Output: 11
6 integers in the given range belong to 3 different shuffle pairs, 5 integers belong to 2 different ones.
Example 5
Input: $from = 1030, $to = 1130, $count = 1
Output: 2
There are 2 integers between 1020 and 1120 that belong to at least one shuffle pair:
1035, the other element is 3105 (witness k = 3)
1089, the other element is 9801 (witness k = 9)
Last date to submit the solution 23:59 (UK Time) Sunday 7th December 2025.
