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: Reverse Existence
10. TASK #2: Prefix Suffix
HEADLINES
Welcome to the Week #377 of The Weekly Challenge.
Abigail is back again. I was expecting to see regex magic from him this time. If you haven’t seen it already then here it is for you.
Ideally, this needed some explanation, atleast for me.
my $tag_re = qr {
(?(DEFINE)
(?<WS> [ \t\n\r\f]+)
(?<OPT_WS> [ \t\n\r\f]*)
(?<ASCII_ALPHA> [a-zA-Z])
(?<ASCII_ALPHANUM> [a-zA-Z0-9])
(?<EQ> (?: (?&OPT_WS) = (?&OPT_WS)))
(?<TAG_NAME> (?: (?&ASCII_ALPHA) (?&ASCII_ALPHANUM)*))
(?<ATTR_NAME> (?[ \p{Any} - \p{Control} -
[\x{00} \t\n\r\f"'=/>]])+)
(?<ATTR_VAL_UNQUOTED> (?[\p{Any} - [\x{00}\p{Control}] -
[ \t\n\r\f] - ['"=<>`]])+)
(?<ATTR_VAL_SINGLE_QUOTED> ' (?[ \p{Any} - [\x{00}'] -
(\p{Control} - [ \t\n\r\f])])* ')
(?<ATTR_VAL_DOUBLE_QUOTED> " (?[ \p{Any} - [\x{00}"] -
(\p{Control} - [ \t\n\r\f])])* ")
(?<ATTR_EMPTY> (?&ATTR_NAME))
(?<ATTR_UNQUOTED> (?:(?&ATTR_NAME) (?&EQ)
(?&ATTR_VAL_UNQUOTED) (?!/)))
(?<ATTR_SINGLE_QUOTED> (?:(?&ATTR_NAME) (?&EQ)
(?&ATTR_VAL_SINGLE_QUOTED)))
(?<ATTR_DOUBLE_QUOTED> (?:(?&ATTR_NAME) (?&EQ)
(?&ATTR_VAL_DOUBLE_QUOTED)))
(?<ATTR> (?:(?&WS) (?: (?&ATTR_EMPTY) |
(?&ATTR_UNQUOTED) |
(?&ATTR_SINGLE_QUOTED) |
(?&ATTR_DOUBLE_QUOTED))))
(?<ATTR_LIST> (?&ATTR)*)
(?<START_TAG> < (?&TAG_NAME) (?&ATTR_LIST) (?&OPT_WS) /?>)
(?<END_TAG> </ (?&TAG_NAME) (?&OPT_WS) >)
(?<TAG> (?:(?&START_TAG) | (?&END_TAG)))
)
(?&TAG)
}x;
Below is my contributions to the Task #1 of Week #376.
Perl: source code
sub same_color {
my ($c1, $c2) = @_;
my $sum1 = (ord(substr($c1, 0, 1)) - 97) + substr($c1, 1);
my $sum2 = (ord(substr($c2, 0, 1)) - 97) + substr($c2, 1);
return ($sum1 % 2) == ($sum2 % 2)?("true"):("false");
}
Raku: source code
sub same_color($c1, $c2) {
my $sum1 = ($c1.substr(0, 1).ord - 97) + $c1.substr(1);
my $sum2 = ($c2.substr(0, 1).ord - 97) + $c2.substr(1);
return ($sum1 % 2) == ($sum2 % 2) ?? "true" !! "false";
}
Python: source code
def same_color(c1, c2):
sum1 = (ord(c1[0]) - ord('a')) + int(c1[1:])
sum2 = (ord(c2[0]) - ord('a')) + int(c2[1:])
return "true" if (sum1 % 2) == (sum2 % 2) else "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 |
372 |
51 | 23 | 15 |
373 |
47 | 21 | 18 |
374 |
43 | 21 | 14 |
375 |
43 | 21 | 15 |
376 |
40 | 19 | 14 |
Last 5 weeks guest contribution stats. Thank you each and every guest contributors for your time and efforts.
Week |
Guests |
Contributions |
Languages |
372 |
15 | 73 | 22 |
373 |
15 | 65 | 23 |
374 |
16 | 50 | 16 |
375 |
15 | 51 | 15 |
376 |
13 | 45 | 25 |
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 (4424)
2. Rust (1169)
3. C (1035)
4. Haskell (911)
5. Ruby (911)
6. Lua (896)
7. C++ (727)
8. Go (687)
9. JavaScript (640)
10. Java (532)
Blogs with Creative Title
1. Doubled Chessboard by Arne Sommer.
2. Doubled Words by Bob Lied.
3. Chess Solo by Jorg Sommrey.
4. A 1-Bit Chessboard and Fancy Separators by Matthias Muth.
5. You might think I’m crazy, but I don’t even care by Packy Anderson.
6. Squares and pairs by Peter Campbell Smith.
7. Half a Chessboard by Roger Bell_West.
8. Double chessboard by Simon Green.
GitHub Repository Stats
1. Commits: 49,960 (+105)
2. Pull Requests: 14,216 (+34)
3. Contributors: 279
4. Fork: 352
5. Stars: 214 (+1)
SPONSOR
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 - 376 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 #376.
Please find past solutions by respected guests. Please share your creative solutions in other languages.
Task 1: Reverse Existence
Submitted by: Mohammad Sajid Anwar
You are given a string.
Write a script to find whether any substring of length 2 is also present in the reverse of the given string.
Example 1
Input: $str = "abcba"
Output: true
Reverse of given string is "abcba".
The substring "ab" in original string is also present in the reverse string too.
Example 2
Input: $str = "racecar"
Output: true
The substring "ce" is present in both.
Example 3
Input: $str = "abcd"
Output: false
Example 4
Input: $str = "banana"
Output: true
The substring "an" is present in both.
Example 5
Input: $str = "hello"
Output: true
The substring "ll" is present in both.
Task 2: Prefix Suffix
Submitted by: Mohammad Sajid Anwar
You are given an array of strings.
Write a script to find if the two strings (str1, str2) in the given array such that str1 is prefix and suffix of str2. Return the total count of such pairs.
Example 1
Input: @array = ("a", "aba", "ababa", "aa")
Output: 4
$array[0], $array[1]: "a" is a prefix and suffix of "aba"
$array[0], $array[2]: "a" is a prefix and suffix of "ababa"
$array[0], $array[3]: "a" is a prefix and suffix of "aa"
$array[1], $array[2]: "aba" is a prefix and suffix of "ababa"
Example 2
Input: @array = ("pa", "papa", "ma", "mama")
Output: 2
$array[0], $array[1]: "pa" is a prefix and suffix of "papa"
$array[2], $array[3]: "ma" is a prefix and suffix of "mama"
Example 3
Input: @array = ("abao", "ab")
Output: 0
Example 4
Input: @array = ("abab", "abab")
Output: 1
$array[0], $array[1]: "abab" is a prefix and suffix of "abab"
Example 5
Input: @array = ("ab", "abab", "ababab")
Output: 3
$array[0], $array[1]: "ab" is a prefix and suffix of "abab"
$array[0], $array[2]: "ab" is a prefix and suffix of "ababab"
$array[1], $array[2]: "abab" is a prefix and suffix of "ababab"
Example 6
Input: @array = ("abc", "def", "ghij")
Output: 0
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 14th June 2026.