The Weekly Challenge - 248

Monday, Dec 18, 2023| Tags: Perl, Raku

TABLE OF CONTENTS


01. HEADLINES

02. SPONSOR

03. RECAP

04. PERL REVIEW

05. RAKU REVIEW

06. CHART

07. NEW MEMBERS

08. GUESTS

09. TASK #1: Shortest Distance

10. TASK #2: Submatrix Sum


HEADLINES


Welcome to the Week #248 of The Weekly Challenge.

Happy Holiday season to Team PWC members. I would like to take this opportunity to thank each member for the support and encouragement. With new year just couple of weeks behind, let us all enjoy the holiday break. I hope you find little time in between to play with Perl and Raku magic.

It has been great pleasure revisiting some of the blog post for Advent Calendar.


Advent Calendar 2023

 Day Article   Author
   1     Third Highest and Maximum (Bit-Wise) XOR     Laurent Rosenfeld  
   2     Maximum sum of pair minimums     Bob Lied  
   3     Minimum Index Sum / Duplicate and Missing     James Smith  
   4     Give A Little Bit     Dave Jacoby  
   5     Kill And Win / Number Collision     Avery Adams  
   6     Lead to Gold and 1 2 3     Peter Campbell Smith  
   7     Wow: Another oneliner! But also a complete BFS…!     Matthias Muth  
   8     Collect Points     Flavio Poletti  
   9     Odd one Out / Number Placement     Robbie Hatley  
   10     Sorted Matrix / Max Number     Stephen G Lynn  
   11     Sorted Squares / Travel Expenditure     W. Luis Mochan  
   12     Common Squares     Simon Green  
   13     Raku Members     Arne Sommer  
   14     Counting Boxes     Roger Bell_West  
   15     Sentenced To Compute Differences     Adam Russell  
   16     Counting Fridays the 13th     Andrew Shitov  
   17     Sums and Swaps     Luca Ferrari  
   18     Similar Words / Frequency Sort     Lubos Kolouch  

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

  Week      Perl       Raku       Blog   
   243       63       34       28   
   244       55       36       29   
   245       53       30       28   
   246       43       26       23   
   247       42       22       22   

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

  Week      Guests       Contributions       Languages   
   243       18       85       24   
   244       14       56       17   
   245       16       53       18   
   246       10       39       14   
   247       10       37       14   

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     (2049)
 2. Ruby       (632)
 3. Haskell    (613)
 4. Lua        (556)
 5. Rust       (478)
 6. C          (465)
 7. C++        (448)
 8. BQN        (315)
 9. Go         (307)
10. JavaScript (301)

Blogs with Creative Title


1. The Santa Letters by Arne Sommer.

2. Partridges and Pair Trees by Dave Jacoby.

3. Weighing and Counting Pairs by Jorg Sommrey.

4. arrays everywhere! by Luca Ferrari.

5. Writing Letter Pairs to Santa by Packy Anderson.

6. Santa’s letters by Peter Campbell Smith.

7. Most Frequent Santa by Roger Bell_West.

8. The one about frequency by Simon Green.


GitHub Repository Stats


1. Commits: 35,678 (+88)

2. Pull Requests: 9,239 (+30)

3. Contributors: 239

4. Fork: 301

5. Stars: 164



Our solo sponsor Pete Sergeant has been a great support to keep us motivated. We are lucky that he agreed to continue the journey with us in the year 2023. I would like to personally thank Pete and his entire team for their generosity. It would be great if we could add few more to sponsor the prize money so that we could go back and declare weekly champions as we have done in the past. I hope and wish this will become possible in 2023. The amount doesn’t have to be huge. However, it would be nice to show off bunch of supporters. If an organisation comes forward and supports us then that would be the ultimate achievement.


RECAP


Quick recap of The Weekly Challenge - 247 by Mohammad S 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 #247.

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


Task 1: Shortest Distance

Submitted by: Mohammad S Anwar

You are given a string and a character in the given string.

Write a script to return an array of integers of size same as length of the given string such that:

distance[i] is the distance from index i to the closest occurence of
the given character in the given string.

The distance between two indices i and j is abs(i - j).

Example 1

Input: $str = "loveleetcode", $char = "e"
Output: (3,2,1,0,1,0,0,1,2,2,1,0)

The character 'e' appears at indices 3, 5, 6, and 11 (0-indexed).
The closest occurrence of 'e' for index 0 is at index 3, so the distance is abs(0 - 3) = 3.
The closest occurrence of 'e' for index 1 is at index 3, so the distance is abs(1 - 3) = 2.
For index 4, there is a tie between the 'e' at index 3 and the 'e' at index 5,
but the distance is still the same: abs(4 - 3) == abs(4 - 5) = 1.
The closest occurrence of 'e' for index 8 is at index 6, so the distance is abs(8 - 6) = 2.

Example 2

Input: $str = "aaab", $char = "b"
Output: (3,2,1,0)

Task 2: Submatrix Sum

Submitted by: Jorg Sommrey

You are given a NxM matrix A of integers.

Write a script to construct a (N-1)x(M-1) matrix B having elements that are the sum over the 2x2 submatrices of A,

b[i,k] = a[i,k] + a[i,k+1] + a[i+1,k] + a[i+1,k+1]

Example 1

Input: $a = [
              [1,  2,  3,  4],
              [5,  6,  7,  8],
              [9, 10, 11, 12]
            ]

Output: $b = [
               [14, 18, 22],
               [30, 34, 38]
             ]

Example 2

Input: $a = [
              [1, 0, 0, 0],
              [0, 1, 0, 0],
              [0, 0, 1, 0],
              [0, 0, 0, 1]
            ]

Output: $b = [
               [2, 1, 0],
               [1, 2, 1],
               [0, 1, 2]
             ]


Last date to submit the solution 23:59 (UK Time) Sunday 24th December 2023.


SO WHAT DO YOU THINK ?

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

Contact with me