The Weekly Challenge: 378

6 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: Second Largest Digit

10. TASK #2: Sum of Words

HEADLINES


Welcome to the Week #378 of The Weekly Challenge.

The amount of excitement generated by our guest contributors continues to amaze us with how frequently we witness a shift in rankings! Just a couple of weeks ago we witnessed Ruby’s ranking be usurped by Haskell, but this week we get to see Ruby regain first place overall! The battle will continue to be extremely close between Ruby and Haskell as we can never predict how much effort the contributors to Haskell will put forth to try to reclaim their position as the top language next week.

I also want to recognise W. Luis Mochán for providing so many outstanding one-liner(ish) solutions for Perl. I really enjoy how entertaining and engaging his descriptions are! I would say the same about Arne Sommer, and he consistently provides high quality solutions for Raku also. I feel that Jaldhar H. Vyas and Arne Sommer are among the best contributors to Raku, with superior blogging techniques.

Writing technical blogs is definitely an art in itself. It’s certainly difficult to convey complex technical ideas to a more general audience. I have been a fan of Jorg Sommrey’s contributions for many years (primarily in Perl and J) and I always look forward to his posts that demonstrate how to use J; they are captivating reads!

When it comes to those guest contributors, Abigail and Roger Bell_West think very differently about how to program so it is always a breath of fresh air seeing their unique blend of programming languages in action together. I am particularly fascinated by Abigail’s use of R; it is something I am keen to pick up myself as well!

Switching gears from the world of technology, how many of you are fans of the Football World Cup?

I remember back in my days when I lived in India watching World Cup games on late night with my father. Even though we did prefer cricket as our main sport, we would still watch the football World Cup. Here in England, it is impossible to escape the game especially whenever World Cup comes around. My biggest hope at this point is for England to win! I have not seen any matches this year, but I will probably watch the semi-finals or final, if England moves on. Maybe 2026 is the year that England will finally win!

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

Perl: source code


sub reverse_substr_exists {
    my ($str) = @_;

    my $rev = reverse $str;
    for my $i (0 .. length($str) - 2) {
        my $sub = substr($str, $i, 2);
        return "true" if index($rev, $sub) != -1;
    }

    return "false";
}

Raku: source code


sub reverse-substr-exists($str) {
    my $rev = $str.flip;
    for 0 .. $str.chars - 2 -> $i {
        my $sub = $str.substr($i, 2);
        return "true" if $rev.index($sub).defined;
    }

    return "false";
}

Python: source code


def reverse_substr_exists(string):
    rev = string[::-1]
    for i in range(len(string) - 1):
        sub = string[i:i+2]
        if rev.find(sub) != -1:
            return "true"
    return "false"

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   
   373       47       21       18   
   374       43       21       14   
   375       43       21       15   
   376       42       21       15   
   377       41       21       12   


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

  Week      Guests       Contributions       Languages   
   373       15       65       23   
   374       16       50       16   
   375       15       51       15   
   376       13       45       25   
   377       12       63       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     (4437)
 2. Rust       (1174)
 3. C          (1037)
 4. Ruby       (916)
 5. Haskell    (915)
 6. Lua        (898)
 7. C++        (729)
 8. Go         (689)
 9. JavaScript (640)
10. Java       (532)

Blogs with Creative Title


1. Prefixed Existence by Arne Sommer.

2. From Start to End and Back by Jorg Sommrey.

3. They run and hide their heads / They might as well be dead… by Packy Anderson.

4. Strings within strings by Peter Campbell Smith.

5. A Suffix to Existence by Roger Bell_West.

6. Existence by Simon Green.


GitHub Repository Stats


1. Commits: 50,053 (+93)

2. Pull Requests: 14,246 (+30)

3. Contributors: 279

4. Fork: 351

5. Stars: 215 (+1)



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

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

Task 1: Second Largest Digit

Submitted by: Mohammad Sajid Anwar

You are given an alphanumeric string.

Write a script to find the second largest distinct digit in the given string. Return -1 if none found.

Example 1

Input: $str = "aaaaa77777"
Output: -1

The only digit in the given string is 7 and there is no second digit.

Example 2

Input: $str = "abcde"
Output: -1

No numerical digits in the given string.

Example 3

Input: $str = "9zero8eight7seven9"
Output: 8

Example 4

Input: $str = "xyz9876543210"
Output: 8

Example 5

Input: $str = "4abc4def2ghi8jkl2"
Output: 4

Task 2: Sum of Words

Submitted by: Mohammad Sajid Anwar

You are given three strings consisting of lower case English letters ‘a’ to ‘j’ only. The letter value of a = 0, b = 1, c = 3, etc.

Write a script to find if sum of first two strings return the third string.

Example 1

Input: $str1 = "acb", $str2 = "cba", $str3 = "cdb"
Output: true

$str1 = "acb" = 021
$str2 = "cba" = 210
$str3 = "cdb" = 231
$str1 + $str2 = $str3

Example 2

Input: $str1 = "aab", $str2 = "aac", $str3 = "ad"
Output: true

$str1 = "aab" = 001
$str2 = "aac" = 002
$str3 = "ad"  = 03

Example 3

Input: $str1 = "bc", $str2 = "je", $str3 = "jg"
Output: false

$str1 = "bc" = 12
$str2 = "je" = 94
$str3 = "jg" = 96

Example 4

Input: $str1 = "a", $str2 = "aaaa", $str3 = "aa"
Output: true

$str1 = "a"    = 0
$str2 = "aaaa" = 0000
$str3 = "aa"   = 00

Example 5

Input: $str1 = "c", $str2 = "d", $str3 = "h"
Output: false

$str1 = "c" = 2
$str2 = "d" = 3
$str3 = "h" = 7

Example 6

Input: $str1 = "gfi", $str2 = "hbf", $str3 = "bdhd"
Output: true

$str1 =  "gfi" =  658
$str2 =  "hbf" =  715
$str3 = "bdhd" = 1373

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 21st June 2026.