The Weekly Challenge - 306

Monday, Jan 27, 2025| 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: Odd Sum

10. TASK #2: Last Element


HEADLINES


Welcome to the Week #306 of The Weekly Challenge.

Let us all welcome a new member, Jeffrey “japhy” Pinyan, an experienced Perl hacker from USA. Thanks for the first contributions in Perl.

Welcome back, Richard Park, and thanks for your contributions in APL.

By the way, did you notice that we are now using the latest Perl logo? Thanks to Thibault Duponchelle for helping with the new logo.

The Week #305 turned out to be the best week of the year 2025 as you can see figures below:

  Week      303       304       305   
   Contributions       70       72       84   
   Participants       26       26       28   

Even for guest contributions, Week #305 is the best week too.

  Week      303       304       305   
   Contributions       37       45       46   
   Participants       8       8       9   

I am looking forward for the week where we get 100+ regular contributions and 50+ guest contributions.

Can we please get that figure in the Week #306?


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

  Week      Perl       Raku       Blog   
   301       45       18       13   
   302       39       20       16   
   303       40       18       12   
   304       38       21       13   
   305       42       21       21   

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

  Week      Guests       Contributions       Languages   
   301       9       39       15   
   302       12       48       19   
   303       8       37       15   
   304       8       45       19   
   305       9       46       17   

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     (3161)
 2. Rust       (836)
 3. Ruby       (765)
 4. Haskell    (741)
 5. Lua        (682)
 6. C          (590)
 7. C++        (583)
 8. JavaScript (528)
 9. Go         (452)
10. BQN        (408)

Blogs with Creative Title


1. Prefixed Alien by Arne Sommer.

2. Use Proxy by Dave Jacoby.

3. Alien Primes by Jorg Sommrey.

4. Sorting and Nested Loops by Luca Ferrari.

5. Binary aliens by Peter Campbell Smith.

6. Binary Aliens by Roger Bell_West.


GitHub Repository Stats


1. Commits: 42,062 (+79)

2. Pull Requests: 11,478 (+30)

3. Contributors: 257 (+1)

4. Fork: 324 (+1)

5. Stars: 182



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


Jeffrey "japhy" Pinyan, an experience Perl hacker from USA 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 #305.

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


Task 1: Odd Sum

Submitted by: Mohammad Sajid Anwar

You are given an array of positive integers, @ints.

Write a script to return the sum of all possible odd-length subarrays of the given array. A subarray is a contiguous subsequence of the array.

Example 1

Input: @ints = (2, 5, 3, 6, 4)
Output: 77

Odd length sub-arrays:
(2) => 2
(5) => 5
(3) => 3
(6) => 6
(4) => 4
(2, 5, 3) => 10
(5, 3, 6) => 14
(3, 6, 4) => 13
(2, 5, 3, 6, 4) => 20

Sum => 2 + 5 + 3 + 6 + 4 + 10 + 14 + 13 + 20 => 77

Example 2

Input: @ints = (1, 3)
Output: 4

Task 2: Last Element

Submitted by: Mohammad Sajid Anwar

You are given a array of integers, @ints.

Write a script to play a game where you pick two biggest integers in the given array, say x and y. Then do the following:

a) if x == y then remove both from the given array
b) if x != y then remove x and replace y with (y - x)

At the end of the game, there is at most one element left.

Return the last element if found otherwise return 0.

Example 1

Input: @ints = (3, 8, 5, 2, 9, 2)
Output: 1

Step 1: pick 8 and 9 => (3, 5, 2, 1, 2)
Step 2: pick 3 and 5 => (2, 2, 1, 2)
Step 3: pick 2 and 1 => (1, 2, 2)
Step 4: pick 2 and 1 => (1, 2)
Step 5: pick 1 and 2 => (1)

Example 2

Input: @ints = (3, 2, 5)
Output: 0

Step 1: pick 3 and 5 => (2, 2)
Step 2: pick 2 and 2 => ()


Last date to submit the solution 23:59 (UK Time) Sunday 2nd January 2025.


SO WHAT DO YOU THINK ?

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

Contact with me