The Weekly Challenge - 355

Monday, Jan 5, 2026| 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: Thousand Separator

10. TASK #2: Mountain Array


HEADLINES


Welcome to the Week #355 of The Weekly Challenge.

Happy New Year 2026 everyone.

Today is the first Monday of the month and time to declare the next champion. With great pride, I announce Mark Anderson the Champion of the Month. He was last declared champion in June 2020. Congratulations Mark. He is currently ranked #19 in the leaderboard with total score 1194. As of today, he shared 21 Perl and 571 Raku solutions, on top 5 blog posts as well. Thank you, Mark, for your support and encouragements.

Let’s all welcome a new member, Anthony Rowe, an expert in Python. Thank you, Anthony, for your first contributions in Python.

I noticed another change in raking for guest languages. Go has moved up one position and now rank #7. In all of these, Python, sitting comfortable at the top position and nobody is anywhere close to threaten that position.

One more thing, I noticed a fellow team member, Marc Perry, shared an interesting analysis of my contribution in Perl to the Task #1 of Week #353. You can check out the details here. Thank you, Marc.


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

Perl: source code

sub min_abs_diff {
    my @ints = @{ $_[0] };

    my @a = sort { $a <=> $b } @ints;
    my $m = 9**9;
    for (0 .. $#a - 1) {
        ($a[$_+1] - $a[$_]) < $m && ($m = $a[$_+1] - $a[$_]);
    }

    [
        map  { [ $a[$_], $a[$_+1] ]    }
        grep { $a[$_+1] - $a[$_] == $m }
        0 .. $#a - 1
    ];
}

Raku: source code

sub min-abs-diff(@ints) {
    my @a = @ints.sort: { $^a <=> $^b };
    my $m = 9**9;

    for 0 .. @a.end - 1 -> $i {
        my $diff = @a[$i+1] - @a[$i];
        if $diff < $m {
            $m = $diff;
        }
    }

    my @pairs = (0 .. @a.end - 1)
        .grep({ @a[$_+1] - @a[$_] == $m })
        .map({ [ @a[$_], @a[$_+1] ] });

    return @pairs == 1 ?? @pairs[0] !! @pairs;
}

Python: source code

def min_abs_diff(ints):
    a = sorted(ints)
    m = 9**9

    for i in range(len(a) - 1):
        diff = a[i+1] - a[i]
        if diff < m:
            m = diff

    return [
        [a[i], a[i+1]]
        for i in range(len(a) - 1)
        if a[i+1] - a[i] == m
    ]

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   
   350       50       19       19   
   351       52       22       15   
   352       52       21       26   
   353       52       20       23   
   354       47       23       16   

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

  Week      Guests       Contributions       Languages   
   350       15       61       18   
   351       15       67       23   
   352       16       73       22   
   353       14       69       19   
   354       14       59       18   

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     (3956)
 2. Rust       (1080)
 3. Ruby       (860)
 4. Haskell    (847)
 5. Lua        (820)
 6. C++        (680)
 7. Go         (614)
 8. JavaScript (612)
 9. C          (596)
10. BQN        (497)

Blogs with Creative Title


1. MAD Shift by Arne Sommer.

2. Shifted Differences by Jorg Sommrey.

3. Min Abs Diff Shift Grid. What?? by Matthias Muth.

4. Some Grids by Packy Anderson.

5. Mad numbers and shifty grid by Peter Campbell Smith.

6. Min Grid Diffs the Shift by Roger Bell_West.

7. New Year, New Challenges by Simon Green.


GitHub Repository Stats


1. Commits: 47,144 (+169)

2. Pull Requests: 13,294 (+65)

3. Contributors: 271 (+1)

4. Fork: 346 (+2)

5. Stars: 207 (+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 - 354 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


Anthony Rowe, Python 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 #354.

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


Task 1: Thousand Separator

Submitted by: Mohammad Sajid Anwar

You are given a positive integer, $int.

Write a script to add thousand separator, , and return as string.

Example 1

Input: $int = 123
Output: "123"

Example 2

Input: $int = 1234
Output: "1,234"

Example 3

Input: $int = 1000000
Output: "1,000,000"

Example 4

Input: $int = 1
Output: "1"

Example 5

Input: $int = 12345
Output: "12,345"

Task 2: Mountain Array

Submitted by: Mohammad Sajid Anwar

You are given an array of integers, @ints.

Write a script to return true if the given array is a valid mountain array.

An array is mountain if and only if:
1) arr.length >= 3
and
2) There exists some i with 0 < i < arr.length - 1 such that:
arr[0] < arr[1]     < ... < arr[i - 1] < arr[i]
arr[i] > arr[i + 1] > ... > arr[arr.length - 1]

Example 1

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

Example 2

Input: @ints = (0, 2, 4, 6, 4, 2, 0)
Output: true

Example 3

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

Example 4

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

Example 5

Input: @ints = (1, 3, 2)
Output: true


Last date to submit the solution 23:59 (UK Time) Sunday 11th January 2026.


SO WHAT DO YOU THINK ?

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

Contact with me