The Weekly Challenge - 352

Monday, Dec 15, 2025| Tags: Perl, Raku

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: Match String

10. TASK #2: Binary Prefix


HEADLINES


Welcome to the Week #352 of The Weekly Challenge.

Let us all welcome new member, Matt Martini, to Team PWC. Thanks Matt for contributions in Perl for weeks #316, #318, #349 and #351.

HVukman shared solutions in Factor, Task #1 and Task #2 for the first time. The only member who shared solutions in Factor before was Raghu R. Anyone curious to know what this language is all about, please follow this page.

Talking about guest languages, Go language has moved up one rank to #8. Well done all those who contributed in Go.

Some interesting facts about contributions in the year 2025 as of today 2025-12-15.


+-----------------+-------------------------------------------+-------+
| Contributions   | Weeks                                     | Total |
+-----------------+-------------------------------------------+-------+
| >= 100          | #325, #326, #330, #331, #332, #333, #341  |    7  |
+-----------------+-------------------------------------------+-------+
| >= 90 and < 100 | #309, #312, #316, #320, #321, #322, #323, |   14  |
|                 | #324, #328, #329, #334, #347, #348, #349  |       |
+-----------------+-------------------------------------------+-------+
| >= 80 and < 90  | #305, #308, #311, #313, #317, #318, #327, |   20  |
|                 | #335, #336, #337, #338, #339, #340, #342, |       |
|                 | #343, #344, #345, #346, #350, #351        |       |
+-----------------+-------------------------------------------+-------+
| >= 70 and < 80  | #303, #304, #307, #310, #314, #315, #329  |    7  |
+-----------------+-------------------------------------------+-------+
| >= 50 and < 70  | #306                                      |    1  |
+-----------------+-------------------------------------------+-------+

Below is my contributions to the Task #1 of Week #351.

Perl: source code

sub special_average {
    my @nums = @_;
    return 0 unless @nums;

    my $min = min @nums;
    my $max = max @nums;

    my @filtered = grep { $_ != $min && $_ != $max } @nums;
    return 0 unless @filtered;

    my $sum = sum @filtered;

    return $sum / @filtered;
}

Raku: source code

sub special-average(*@nums) {
    return 0 unless @nums.elems;

    my $min = @nums.min;
    my $max = @nums.max;

    my @filtered = @nums.grep: { $_ != $min && $_ != $max };
    return 0 unless @filtered.elems;

    my $sum = [+] @filtered;

    return $sum / @filtered.elems;
}

Python: source code

def special_average(nums):
    if not nums:
        return 0

    min_val = min(nums)
    max_val = max(nums)

    filtered = [x for x in nums if x != min_val and x != max_val]
    if not filtered:
        return 0

    return sum(filtered) / len(filtered)

Thank you Team PWC, once again.

Happy Hacking!!


Advent Calendar 2025


Contributions to the Advent Calendar so far by fellow members.


Day 1: 3-digits Even/Delete and Earn by Ali Moradi.

Day 2: Not Modified by Dave Jacoby.

Day 3: Alien Primes by Jorg Sommrey.

Day 4: Odd game by Peter Campbell Smith.

Day 5: Don’t Get Trapped by Matthias Muth.

Day 6: Exclusive or Common by Arne Sommer.

Day 7: Perl and Raku mainly by Luca Ferrari.

Day 8: Arrays Intersection/Sort Odd Even by Jaldhar H. Vyas.

Day 9: Lower the Sum by Roger Bell_West.

Day 10: Minimum Time/Balls and Boxes by W. Luis Mochan.

Day 11: Reverse Broken Keys for Letters by Adam Russell.

Day 12: Equal Strings/Sort Column by Robbie Hatley.

Day 13: Sub circular by Simon Green.

Day 14: Reverse Equals by Bob Lied.

Day 15: Count the Minimum Common Word by Packy Anderson.



Last 5 weeks mainstream contribution stats. Thank you Team PWC for your support and encouragements.

  Week      Perl       Raku       Blog   
   347       47       21       24   
   348       47       23       26   
   349       50       23       26   
   350       48       17       17   
   351       51       20       13   

Last 5 weeks guest contribution stats. Thank you each and every guest contributors for your time and efforts.

  Week      Guests       Contributions       Languages   
   347       16       67       21   
   348       16       70       23   
   349       18       83       24   
   350       13       57       17   
   351       14       65       22   

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     (3822)
 2. Rust       (1066)
 3. Ruby       (854)
 4. Haskell    (841)
 5. Lua        (808)
 6. C++        (674)
 7. JavaScript (606)
 8. Go         (598)
 9. C          (596)
10. BQN        (487)

Blogs with Creative Title


1. Special Progression by Arne Sommer.

2. Average Progression by Jorg Sommrey.

3. A Special Sack Race by Matthias Muth.

4. A pretty average progression… by Packy Anderson.

5. Fun with arrays by Peter Campbell Smith.

6. Special Arithmetic by Roger Bell_West.

7. Average Progression by Simon Green.


GitHub Repository Stats


1. Commits: 46,722 (+121)

2. Pull Requests: 13,140 (+37)

3. Contributors: 268 (+1)

4. Fork: 344 (+1)

5. Stars: 203 (+1)



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 - 351 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


Matt Martini, Perl 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 #351.

Please find past solutions by respected guests. Please share your creative solutions in other languages.


Task 1: Match String

Submitted by: Mohammad Sajid Anwar

You are given an array of strings.

Write a script to return all strings that are a substring of another word in the given array in the order they occur.

Example 1

Input: @words = ("cat", "cats", "dog", "dogcat", "dogcat", "rat", "ratcatdogcat")
Output: ("cat", "dog", "dogcat", "rat")

Example 2

Input: @words = ("hello", "hell", "world", "wor", "ellow", "elloworld")
Output: ("hell", "world", "wor", "ellow")

Example 3

Input: @words = ("a", "aa", "aaa", "aaaa")
Output: ("a", "aa", "aaa")

Example 4

Input: @words = ("flower", "flow", "flight", "fl", "fli", "ig", "ght")
Output: ("flow", "fl", "fli", "ig", "ght")

Example 5

Input: @words = ("car", "carpet", "carpenter", "pet", "enter", "pen", "pent")
Output: ("car", "pet", "enter", "pen", "pent")

Task 2: Binary Prefix

Submitted by: Mohammad Sajid Anwar

You are given an array, @nums, where each element is either 0 or 1.

Define xi as the number formed by taking the first i+1 bits of @nums (from $nums[0] to $nums[i]) and interpreting them as a binary number, with $nums[0] being the most significant bit.

For example:

If @nums = (1, 0, 1), then:

x0 = 1 (binary 1)
x1 = 2 (binary 10)
x2 = 5 (binary 101)

For each i, check whether xi is divisible by 5.

Write a script to return an array @answer where $answer[i] is true if x<sub>i</sub> is divisible by 5, otherwise false.

Example 1

Input: @nums = (0,1,1,0,0,1,0,1,1,1)
Output: (true, false, false, false, false, true, true, false, false, false)

Binary numbers formed (decimal values):
         0: 0
        01: 1
       011: 3
      0110: 6
     01100: 12
    011001: 25
   0110010: 50
  01100101: 101
 011001011: 203
0110010111: 407

Example 2

Input: @num = (1,0,1,0,1,0)
Output: (false, false, true, true, false, false)

     1: 1
    10: 2
   101: 5
  1010: 10
 10101: 21
101010: 42

Example 3

Input: @num = (0,0,1,0,1)
Output: (true, true, false, false, true)

    0: 0
   00: 0
  001: 1
 0010: 2
00101: 5

Example 4

Input: @num = (1,1,1,1,1)
Output: (false, false, false, true, false)

    1: 1
   11: 3
  111: 7
 1111: 15
11111: 31

Example 5

Input: @num = (1,0,1,1,0,1,0,0,1,1)
Output: (false, false, true, false, false, true, true, true, false, false)

         1: 1
        10: 2
       101: 5
      1011: 11
     10110: 22
    101101: 45
   1011010: 90
  10110100: 180
 101101001: 361
1011010011: 723


Last date to submit the solution 23:59 (UK Time) Sunday 21st December 2025.


SO WHAT DO YOU THINK ?

If you have any suggestions or ideas then please do share with us.

Contact with me