The Weekly Challenge - 314

Monday, Mar 24, 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: Equal Strings

10. TASK #2: Sort Column


HEADLINES


Welcome to the Week #314 of The Weekly Challenge.

We have a new member, Darren Yates, joining Team PWC.

Welcome aboard! I hope you find our group fun and entertaining while also surprising you with its magic. Thanks for your first contributions in Perl.

As some of you already know, that I am also the co-editor of Perl Weekly newsletter. I edit the newsletter every alternate week. I take the even numbered weeks and Gabor Szabo, the chief editor, takes the odd numbered weeks. It is always published on Monday morning, just like The Weekly Challenge.

This week is an odd numbered week, so I have a break. However, even when I am off, I still work on The Weekly Challenge section of the newsletter.

What does that mean?

It means, I go through all weekly contributions and collect all the blog posts. After that, I carefully review each one and add it to the newsletter along with my short commentary.

As you can imagine, this is a time-consuming exercise. I do this while also preparing the new weekly challenge shoutout.

The downside?, I don’t get to check contributions without a blog post. Trust me, I hate this! I truly want to go through all submissions because I know personally how brilliant each one of you is.

Take, for example, James Smith, our former member he always comes up brilliant solutions every week but we never got to capture them in our knowledge bank, not because he stopped us from doing so, but simply because of how he shared them.

Why?

Usually he shares his creation in a Facebook group called Perl Programmers and mostly as an image. making it difficult to copy and paste, as you know.

Just like, James Smith, we have many other brilliant minds in our team. One day, when we look back, I am sure we will be proud of what have accomplished. The next generation of creative minds will definitely appreciate the work we are leaving behind.

I don’t usually talk much because of time constraints but today is special as I am overwhemled by the quality contributions this week.

Once again, I sincerely apologise to those I miss regularly because they don’t submit a blog. I truly admire your work as well!

If I name just one or two people, it would be unfair in my opinion but I can’t resist.

So please forgive me, I have to mention some names today, in no particular order.

For a complete review, you can check out the latest newsletter, if it is published before ours.


Jorg Sommrey


sub broken_keys ($name, $typed) {
    $typed =~ /^(??{$name =~ s#.#\Q$&\E+#gr})$/;
}

Mathias Muth


sub broken_keys( $name, $typed ) {
    my $pattern = join "", map "$_+", split "", $name;
    return $typed =~ /^$pattern$/;
}

Peter Campbell Smith


sub broken_keys {

    my ($correct, $wrong, $pattern);

    ($correct, $wrong) = @_;

    # build a regular expression
    $pattern .= qq/[$_]+/ for split('', $correct);

    # use it to produce output
    say qq[\nInput:  \$correct = '$correct', \$wrong = '$wrong'];
    say qq[Output: ] . ($wrong =~ m|^$pattern$| ? 'true' : 'false');
}

Simon Green


sub main ( $name, $typed ) {
    my $r = '^' . join( '+', map { quotemeta } split //, $name ) . '+$';
    say $typed =~ $r ? 'true' : 'false';
}


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

  Week      Perl       Raku       Blog   
   309       50       21       19   
   310       44       19       13   
   311       42       21       16   
   312       46       21       26   
   313       51       19       13   

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

  Week      Guests       Contributions       Languages   
   309       13       56       21   
   310       11       44       16   
   311       11       46       17   
   312       13       56       20   
   313       11       49       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     (3271)
 2. Rust       (868)
 3. Ruby       (781)
 4. Haskell    (759)
 5. Lua        (698)
 6. C++        (599)
 7. C          (590)
 8. JavaScript (544)
 9. Go         (469)
10. BQN        (424)

Blogs with Creative Title


1. Reverse Broken Keys for Letters by Adam Russell.

2. Reverse Broken by Arne Sommer.

3. Broken Down Letters by Jorg Sommrey.

4. There Is Always a Regular Expression To Solve It by Matthias Muth.

5. Broken letters by Peter Campbell Smith.

6. Broken and Reversed by Roger Bell_West.

7. Broken letters by Simon Green.


GitHub Repository Stats


1. Commits: 42,822 (+117)

2. Pull Requests: 11,751 (+40)

3. Contributors: 257

4. Fork: 327 (+2)

5. Stars: 188 (+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 - 313 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


Darren Yates, an expert Perl hacker joined the 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 #313.

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


Task 1: Equal Strings

Submitted by: Mohammad Sajid Anwar

You are given three strings.

You are allowed to remove the rightmost character of a string to make all equals.

Write a script to return the number of operations to make it equal otherwise -1.

Example 1

Input: $s1 = "abc", $s2 = "abb", $s3 = "ab"
Output: 2

Operation 1: Delete "c" from the string "abc"
Operation 2: Delete "b" from the string "abb"

Example 2

Input: $s1 = "ayz", $s2 = "cyz", $s3 = "xyz"
Output: -1

Example 3

Input: $s1 = "yza", $s2 = "yzb", $s3 = "yzc"
Output: 3

Task 2: Sort Column

Submitted by: Mohammad Sajid Anwar

You are given a list of strings of same length.

Write a script to make each column sorted lexicographically by deleting any non sorted columns.

Return the total columns deleted.

Example 1

Input: @list = ("swpc", "tyad", "azbe")
Output: 2

swpc
tyad
azbe

Column 1: "s", "t", "a" => non sorted
Column 2: "w", "y", "z" => sorted
Column 3: "p", "a", "b" => non sorted
Column 4: "c", "d", "e" => sorted

Total columns to delete to make it sorted lexicographically.

Example 2

Input: @list = ("cba", "daf", "ghi")
Output: 1

Example 3

Input: @list = ("a", "b", "c")
Output: 0


Last date to submit the solution 23:59 (UK Time) Sunday 30th March 2025.


SO WHAT DO YOU THINK ?

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

Contact with me