The Weekly Challenge - 297

Monday, Nov 25, 2024| 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: Contiguous Array

10. TASK #2: Semi-Ordered Permutation


HEADLINES


Welcome to the Week #297 of The Weekly Challenge.

Welcome back, Adam Russell and thanks for catching up with last week solutions in Perl and Prolog alongwith bonus blog post.

Just one week left before the Advent Calendar kicks in. Looks like we are going to follow the tradition route this time too. Enjoy the holiday season.


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

  Week      Perl       Raku       Blog   
   292       35       13       14   
   293       57       26       15   
   294       37       21       10   
   295       45       20       24   
   296       49       19       16   

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

  Week      Guests       Contributions       Languages   
   292       7       23       14   
   293       11       50       16   
   294       10       46       18   
   295       10       45       18   
   296       11       49       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     (3057)
 2. Rust       (798)
 3. Ruby       (747)
 4. Haskell    (723)
 5. Lua        (664)
 6. C          (589)
 7. C++        (565)
 8. JavaScript (510)
 9. Go         (424)
10. BQN        (389)

Blogs with Creative Title


1. String Together a Square by Adam Russell.

2. Squared String by Arne Sommer.

3. Pictures of Matchstick Men by Dave Jacoby.

4. Compressed Matchsticks by Jorg Sommrey.

5. The Run-Length of Matchsticks by Matthias Muth.

6. Compression and Matchsticks by Packy Anderson.

7. Squeezing and Squaring by Peter Campbell Smith.

8. Matchstick Compression by Roger Bell_West.

9. Matchstick compression by Simon Green.


GitHub Repository Stats


1. Commits: 41,285 (+114)

2. Pull Requests: 11,199 (+39)

3. Contributors: 253

4. Fork: 320

5. Stars: 177



With start of Week #268, we have a new sponsor Lance Wicks for the entire year 2024. 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 - 296 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 #296.

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


Task 1: Contiguous Array

Submitted by: Mohammad Sajid Anwar

You are given an array of binary numbers, @binary.

Write a script to return the maximum length of a contiguous subarray with an equal number of 0 and 1.

Example 1

Input: @binary = (1, 0)
Output: 2

(1, 0) is the longest contiguous subarray with an equal number of 0 and 1.

Example 2

Input: @binary = (0, 1, 0)
Output: 2

(1, 0) or (0, 1) is the longest contiguous subarray with an equal number of 0 and 1.

Example 3

Input: @binary = (0, 0, 0, 0, 0)
Output: 0

Example 4

Input: @binary = (0, 1, 0, 0, 1, 0)
Output: 4

Task 2: Semi-Ordered Permutation

Submitted by: Mohammad Sajid Anwar

You are given permutation of $n integers, @ints.

Write a script to find the minimum number of swaps needed to make the @ints a semi-ordered permutation.

A permutation is a sequence of integers from 1 to n of length n containing  each number exactly once.
A permutation is called semi-ordered if the first number is 1 and the last number equals n.

You are ONLY allowed to pick adjacent elements and swap them.

Example 1

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

Swap 2 <=> 1 => (1, 2, 4, 3)
Swap 4 <=> 3 => (1, 2, 3, 4)

Example 2

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

Swap 4 <=> 1 => (2, 1, 4, 3)
Swap 2 <=> 1 => (1, 2, 4, 3)
Swap 4 <=> 3 => (1, 2, 3, 4)

Example 3

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

Already a semi-ordered permutation.


Last date to submit the solution 23:59 (UK Time) Sunday 1st December 2024.


SO WHAT DO YOU THINK ?

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

Contact with me