The Weekly Challenge: 391

5 min read
← Back to Challenges

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: Array Median

10. TASK #2: Arrange Box

HEADLINES


Welcome to the Week #391 of The Weekly Challenge.

It feels great to have consistent contributors. Some even find time to contribute during the holiday break! I do miss a few people, though, but I completely understand that priorities change over time.

Seeing familiar faces return always brings me so much joy. I’d also like to thank everyone for your kind messages, and please accept my apology for not replying to each sweet message individually.

Matthias Muth and Matt Martini proposed having centralised examples every week, and Matthias has been busy creating them. You can find the examples for Week #390 right here, and feel free to join the discussion here if you have any suggestions.

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

Perl: source code


sub decode_string {
    my ($s) = @_;
    1 while $s =~ s/(\d+)\[([^\[\]]*)\]/$2 x $1/eg;
    return $s;
}

Raku: source code


sub decode-string($s is copy) {
    Nil while $s ~~ s:g/ (\d+) '[' (<-[ \[ \] ]>*) ']' /{$1 x $0}/;
    return $s;
}

Python: source code


def decode_string(s: str) -> str:
    pattern = re.compile(r"(\d+)\[([^\[\]]*)\]")
    while True:
        s, count = pattern.subn(lambda m: m.group(2) * int(m.group(1)), s)
        if count == 0:
            break
    return s

Thank you Team PWC, once again.

Happy Hacking!!



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

  Week      Perl       Raku       Blog   
   386       41       19       13   
   387       36       16       12   
   388       39       19       15   
   389       41       18       14   
   390       35       15       15   


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

  Week      Guests       Contributions       Languages   
   386       12       30       10   
   387       11       26       10   
   388       12       70       25   
   389       13       70       23   
   390       10       27       10   

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     (4612)
 2. Rust       (1226)
 3. C          (1069)
 4. Haskell    (954)
 5. Ruby       (943)
 6. Lua        (927)
 7. C++        (751)
 8. Go         (732)
 9. JavaScript (652)
10. Java       (532)

Blogs with Creative Title


1. Decoded Order by Arne Sommer.

2. Weird Ways to Wrangle Words by Bob Lied.

3. Decoded Permutations by Jorg Sommrey.

4. Inside Out and Round We Go by Matthias Muth.

5. How does it feel to decode me like you do? by Packy Anderson.

6. Multiply and order by Peter Campbell Smith.

7. Decode the Order by Roger Bell_West.

8. The First Expansion by Simon Green.

GitHub Repository Stats


1. Commits: 51,308 (+84)

2. Pull Requests: 14,688 (+27)

3. Contributors: 282

4. Fork: 352

5. Stars: 220


With start of Week #355, we have a new sponsor Marc Perry until the end of year 2026. 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. You can find more informations here.

RECAP


Quick recap of The Weekly Challenge - 390 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


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 #390.

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

Task 1: Array Median

Submitted by: Mohammad Sajid Anwar

You are given two sorted arrays.

Write a script to merge the two given sorted arrays and return the median of the merged array.

Example 1

Input: @arr1 = (2), @arr2 = (4)
Output: 3.0

Merged array: (2,4)
Median: (2+4)/2 => 3

Example 2

Input: @arr1 = (1,2,3), @arr2 = (7,8,9,10)
Output: 7.0

Merged array: (1,2,3,7,8,9,10)
Length of merged array is 7, the 4th element is 7.

Example 3

Input: @arr1 = (), @arr2 = (10,20,30,40)
Output: 25.0

Merged array: (10,20,30,40)
Median: (20+30)/2 => 25

Example 4

Input: @arr1 = (100), @arr2 = (1,2,3,4,5,6,7)
Output: 4.5

Merged array: (1,2,3,4,5,6,7,100)
Median: (4+5)/2 => 4.5

Example 5

Input: @arr1 = (1,2,2), @arr2 = (2,2,3)
Output: 2.0

Merged array: (1,2,2,2,2,3)
Median: (2+2)/2 => 2

Task 2: Arrange Box

Submitted by: Mohammad Sajid Anwar

You are given an array of box dimensions.

Write a script to determine the maximum number of these boxes that can fit inside each other in a single stack. For a box to fit inside another, it must be smaller in both dimensions.

Example 1

Input: @boxes = ([1, 3], [3, 5], [6, 8], [2, 4])
Output: 4

Sort by width ascending: ([1, 3], [2, 4], [3, 5], [6, 8])
Extract heights: [3, 4, 5, 8]
[1, 3] -> [2, 4] -> [3, 5] -> [6, 8]

Example 2

Input: @boxes = ([4, 5], [4, 6], [6, 7], [2, 3], [4, 3])
Output: 3

Sort by width ascending: ([2, 3], [4, 6], [4, 5], [4, 3], [6, 7])
Extract heights: (3, 6, 5, 3, 7)
[2, 3] -> [4, 5] -> [6, 7]

Example 3

Input: @boxes = ([5, 5], [5, 5], [5, 5])
Output: 1

Sort by width ascending: ([5, 5], [5, 5], [5, 5])
Extract heights: (5, 5, 5)
[5, 5]

Example 4

Input: @boxes = ([2, 100], [3, 200], [4, 300], [5, 50], [5, 400])
Output: 4

Sort by width ascending: ([2, 100], [3, 200], [4, 300], [5, 400], [5, 50])
Extract heights: (100, 200, 300, 400, 50)
[2, 100] -> [3, 200] -> [4, 300] -> [5, 400]

Example 5

Input: @boxes = ([10, 20], [15, 10], [20, 30], [12, 18], [16, 25])
Output: 3

Sort by width ascending: ([10, 20], [12, 18], [15, 10], [16, 25], [20, 30])
Extract heights: (20, 18, 10, 25, 30)
[15, 10] -> [16, 25] -> [20, 30]

By submitting a response to the challenge you agree that your name or pseudonym, any photograph you supply and any other personal information contained in your submission may be published on this website and the associated mobile app. Last date to submit the solution 23:59 (UK Time) Sunday 20th September 2026.