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: Minimum Time
10. TASK #2: Balls and Boxes
HEADLINES
Welcome to the Week #312
of The Weekly Challenge
.
I wish all members who celebrate the month of Ramadan
. May ALLAH s.w.t.
bless you with peace, happiness and prosperity.
I would also like to congratulate all fellow Indians
for Team India
winning the Champions Trophy 2025
for the second time. It was a close match, I was glued to the TV all Sunday till the last ball. Team New Zealand
played well and gave a tough fight, I must admit.
Back to the main topics, welcome back Kaushik Tunuguntla
after a long break. Thanks for your contributions in Perl and Python. Also the bonus blog post. I hope to see you more regular this time, no pressure though.
I would like to mention one member, Luca Ferrari
, for consistent contributions. Having said, I noticed in recent times we miss the bonus guest language contributions. I hope to see more from him.
There is another member, Adam Russell
, who is on/off
as far as participation is concerned. However when ever he does and he makes a very big impact. Thank you for contributions in Perl and Prolog. Thank you for quality blog post. I loved the use of pack/unpack
with such an ease.
Similarly, Ali Moradi
for creating clean and cute solutions in Perl. Bonus contributions in Java and Modula-3.
How can I miss Raku
master Arne Sommer
for creative blog post every week. This week post was no different.
There are few silent players who impressed me with the energy to keep it going for so long e.g. Roger Bell_West
, Ulrich Rieke
, Athanasius
, Peter Campbell Smith
, W. Luis Mochan
, Mark Anderson
, Wanderdoc
, Thomas Kohler
and many more.
I liked the nature of weekly challenge where you are not bound to it. You are the boss and you decide when you want to contribute. What matters most is the quality contributions. I noticed the GitHub repository for the Team PWC
contribution is growing very fast. It is also very popular outside of the camp. As of today, we have got 187 stars
, very impressive. I hope to get over 200
mark soon. I would keep the collection of knowledge for ever and for next generation to learn from it.
I noticed lots of different flavour of regex, some of them are listed below:
Niels van Dijke
$str =~ s/$re/sum(values %+)/ge;
Kjetil Skotheim
pop() =~ s/./chr(ord$&^32)/ger
E. Choroba
join "", map sum(split //), $str =~ /(.{1,$int})/g;
Jorg Sommrey
$str =~ s/(\p{Lu})|(\p{Ll})/$1 ? lc($1) : uc($2)/egr
Jaldhar H. Vyas
$_ = shift; s/(.)/uc $1 eq $1 ? lc $1: uc $1/ge; say
Matthias Muth
$str =~ s< ([a-z]) | [A-Z] >{ $1 ? uc( $& ) : lc( $& ) }xegr;
Robbie Hatley
y/[a-zA-Z]/[A-Za-z]/,print while <>
Wanderdoc
$str =~ s/(\p{Uppercase}) | (\p{Lowercase}) /defined $1 ? lc $1 : uc $2/xeg;
Last but not least, a gentle reminder to Laurent Rosenfeld
and E. Choroba
to get back to me with your PayPal
account so that prize money can be transferred to you.
Last 5 weeks
mainstream contribution stats. Thank you Team PWC
for your support and encouragements.
Week |
Perl |
Raku |
Blog |
307 |
44 | 20 | 12 |
308 |
44 | 22 | 16 |
309 |
50 | 21 | 19 |
310 |
44 | 19 | 13 |
311 |
40 | 21 | 16 |
Last 5 weeks
guest contribution stats. Thank you each and every guest contributors for your time and efforts.
Week |
Guests |
Contributions |
Languages |
307 |
15 | 61 | 23 |
308 |
14 | 56 | 21 |
309 |
13 | 56 | 21 |
310 |
11 | 44 | 16 |
311 |
11 | 46 | 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 (3239)
2. Rust (860)
3. Ruby (777)
4. Haskell (755)
5. Lua (694)
6. C++ (595)
7. C (590)
8. JavaScript (540)
9. Go (464)
10. BQN (420)
Blogs with Creative Title
1. Lower the Upper Sums! by Adam Russell.
2. Upper Group by Arne Sommer.
3. Flip Groups by Jorg Sommrey.
4. Switch Case? by Kaushik Tunuguntla.
5. two lines by Luca Ferrari.
6. Up and Down and Round and Round by Matthias Muth.
7. gROUP dIGIT sUM by Peter Campbell Smith.
8. Lower the Sum by Roger Bell_West.
GitHub Repository Stats
1. Commits: 42,599 (+91
)
2. Pull Requests: 11,675 (+34
)
3. Contributors: 258 (+1
)
4. Fork: 325 (+2
)
5. Stars: 187 (+1
)
SPONSOR
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 - 311 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 #311.
Please find past solutions by respected guests. Please share your creative solutions in other languages.
Task 1: Minimum Time
Submitted by: Mohammad Sajid Anwar
You are given a typewriter with lowercase english letters a
to z
arranged in a circle.
Typing a character takes 1 sec
. You can move pointer one character clockwise
or anti-clockwise
.
The pointer initially points at a
.
Write a script to return minimum time it takes to print the given string.
Example 1
Input: $str = "abc"
Output: 5
The pointer is at 'a' initially.
1 sec - type the letter 'a'
1 sec - move pointer clockwise to 'b'
1 sec - type the letter 'b'
1 sec - move pointer clockwise to 'c'
1 sec - type the letter 'c'
Example 2
Input: $str = "bza"
Output: 7
The pointer is at 'a' initially.
1 sec - move pointer clockwise to 'b'
1 sec - type the letter 'b'
1 sec - move pointer anti-clockwise to 'a'
1 sec - move pointer anti-clockwise to 'z'
1 sec - type the letter 'z'
1 sec - move pointer clockwise to 'a'
1 sec - type the letter 'a'
Example 3
Input: $str = "zjpc"
Output: 34
Task 2: Balls and Boxes
Submitted by: Mohammad Sajid Anwar
There are $n
balls of mixed colors: red
, blue
or green
. They are all distributed in 10 boxes
labelled 0-9
.
You are given a string describing the location of balls.
Write a script to find the number of boxes containing all three colors. Return 0
if none found.
Example 1
Input: $str = "G0B1R2R0B0"
Output: 1
The given string describes there are 5 balls as below:
Box 0: Green(G0), Red(R0), Blue(B0) => 3 balls
Box 1: Blue(B1) => 1 ball
Box 2: Red(R2) => 1 ball
Example 2
Input: $str = "G1R3R6B3G6B1B6R1G3"
Output: 3
The given string describes there are 9 balls as below:
Box 1: Red(R1), Blue(B1), Green(G1) => 3 balls
Box 3: Red(R3), Blue(B3), Green(G3) => 3 balls
Box 6: Red(R6), Blue(B6), Green(G6) => 3 balls
Example 3
Input: $str = "B3B2G1B3"
Output: 0
Box 1: Green(G1) => 1 ball
Box 2: Blue(B2) => 1 ball
Box 3: Blue(B3) => 2 balls
Last date to submit the solution 23:59 (UK Time) Sunday 16th March 2025
.