The Weekly Challenge - 236

Monday, Sep 25, 2023| 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: Exact Change

10. TASK #2: Array Loops


HEADLINES


Welcome to the Week #236 of The Weekly Challenge.

Let us all welcome two new members to the Team PWC, Yves Orton and Asher Harvey-Smith.

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

  Week      Perl       Raku       Blog   
   230       64       34       26   
   231       68       40       31   
   233       60       35       29   
   234       52       35       24   
   235       61       34       24   

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

  Week      Guests       Contributions       Languages   
   230       15       54       20   
   231       18       83       24   
   233       15       59       16   
   234       12       48       15   
   235       14       78       23   

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     (1827)
 2. Haskell    (590)
 3. Ruby       (590)
 4. Lua        (520)
 5. C          (439)
 6. Rust       (432)
 7. C++        (409)
 8. BQN        (309)
 9. Go         (276)
10. JavaScript (264)

Blogs with Creative Title


1. One Zero by Arne Sommer.

2. Splicing and Dicing by Avery Adams.

3. Steppin’ in a Slide Zone by Bob Lied.

4. integer arrays by Luca Ferrari.

5. Ones Removed and Zeros Duplicated by Matthias Muth.

6. Delete and double by Peter Campbell Smith.

7. One, Zero by Roger Bell_West.

8. Adding and removing integers by Simon Green.


GitHub Repository Stats


1. Commits: 34,335 (+116)

2. Pull Requests: 8,747 (+43)

3. Contributors: 232 (+2)

4. Fork: 290 (+1)

5. Stars: 163



Our solo sponsor Pete Sergeant has been a great support to keep us motivated. We are lucky that he agreed to continue the journey with us in the year 2023. I would like to personally thank Pete and his entire team for their generosity. It would be great if we could add few more to sponsor the prize money so that we could go back and declare weekly champions as we have done in the past. I hope and wish this will become possible in 2023. The amount doesn’t have to be huge. However, it would be nice to show off bunch of supporters. If an organisation comes forward and supports us then that would be the ultimate achievement.


RECAP


Quick recap of The Weekly Challenge - 235 by Mohammad S 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


1. Yves Orton, an expert Perl hacker from Amsterdam joined the Team PWC.

2. Asher Harvey-Smith, an expert hacker from England 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 #235.

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


Task 1: Exact Change

Submitted by: Mohammad S Anwar

You are asked to sell juice each costs $5. You are given an array of bills. You can only sell ONE juice to each customer but make sure you return exact change back. You only have $5, $10 and $20 notes. You do not have any change in hand at first.

Write a script to find out if it is possible to sell to each customers with correct change.

Example 1

Input: @bills = (5, 5, 5, 10, 20)
Output: true

From the first 3 customers, we collect three $5 bills in order.
From the fourth customer, we collect a $10 bill and give back a $5.
From the fifth customer, we give a $10 bill and a $5 bill.
Since all customers got correct change, we output true.

Example 2

Input: @bills = (5, 5, 10, 10, 20)
Output: false

From the first two customers in order, we collect two $5 bills.
For the next two customers in order, we collect a $10 bill and give back a $5 bill.
For the last customer, we can not give the change of $15 back because we only have two $10 bills.
Since not every customer received the correct change, the answer is false.

Example 3

Input: @bills = (5, 5, 5, 20)
Output: true

Task 2: Array Loops

Submitted by: Mark Anderson

You are given an array of unique integers.

Write a script to determine how many loops are in the given array.


To determine a loop: Start at an index and take the number at array[index] and then proceed to that index and continue this until you end up at the starting index.


Example 1

Input: @ints = (4,6,3,8,15,0,13,18,7,16,14,19,17,5,11,1,12,2,9,10)
Output: 3

To determine the 1st loop, start at index 0, the number at that index is 4, proceed to index 4, the number at that index is 15, proceed to index 15 and so on until you're back at index 0.

Loops are as below:
[4 15 1 6 13 5 0]
[3 8 7 18 9 16 12 17 2]
[14 11 19 10]

Example 2

Input: @ints = (0,1,13,7,6,8,10,11,2,14,16,4,12,9,17,5,3,18,15,19)
Output: 6

Loops are as below:
[0]
[1]
[13 9 14 17 18 15 5 8 2]
[7 11 4 6 10 16 3]
[12]
[19]

Example 3

Input: @ints = (9,8,3,11,5,7,13,19,12,4,14,10,18,2,16,1,0,15,6,17)
Output: 1

Loop is as below:
[9 4 5 7 19 17 15 1 8 12 18 6 13 2 3 11 10 14 16 0]


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


SO WHAT DO YOU THINK ?

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

Contact with me