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: Max Str Value
10. TASK #2: Encrypted String
HEADLINES
Welcome to the Week #358 of The Weekly Challenge.
Welcome aboard Alexander Goussas and thanks for your first contributions in Haskell.
This past week was difficult. You may have noticed the reason for my delay in accepting submissions from contributors. However, I expect this week’s operations to proceed more easily than last week. Although, certain weeks can be difficult; however, we will continue to make progress.
I hope you are able to enjoy the Challenge that we’ve prepared for the week. Thank you for being a valuable member of the team and for sharing your expertise with us.
Below is my contributions to the Task #1 of Week #357.
Perl: source code
sub kaprekar_constant {
my ($int) = @_;
my %seen;
my $i;
for ($i = 0; $int != 6174; $i++) {
return -1 if $seen{$int}++;
my $str = sprintf "%04d", $int;
my $a = join "", sort split //, $str;
my $d = reverse $a;
$int = $d - $a;
}
return $i;
}
Raku: source code
sub kaprekar-constant ($int is copy) {
my %seen;
my $i;
loop ($i = 0; $int != 6174; $i++) {
return -1 if %seen{$int}++;
my $str = sprintf "%04d", $int;
my $a = $str.comb.sort.join;
my $d = $a.flip;
$int = $d.Int - $a.Int;
}
return $i;
}
Python: source code
def kaprekar_constant(n: int) -> int:
seen = set()
i = 0
while n != 6174:
if n in seen:
return -1
seen.add(n)
s = f"{n:04d}"
a = "".join(sorted(s))
d = a[::-1]
n = int(d) - int(a)
i += 1
return i
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 |
353 |
54 | 20 | 24 |
354 |
54 | 23 | 16 |
355 |
51 | 23 | 24 |
356 |
44 | 18 | 13 |
357 |
48 | 21 | 23 |
Last 5 weeks guest contribution stats. Thank you each and every guest contributors for your time and efforts.
Week |
Guests |
Contributions |
Languages |
353 |
16 | 73 | 19 |
354 |
15 | 61 | 18 |
355 |
17 | 69 | 21 |
356 |
13 | 39 | 11 |
357 |
16 | 67 | 19 |
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 (4047)
2. Rust (1092)
3. Ruby (864)
4. Haskell (855)
5. Lua (830)
6. C++ (686)
7. Go (624)
8. JavaScript (616)
9. C (600)
10. BQN (499)
Blogs with Creative Title
1. Uniquely Constant by Arne Sommer.
2. Fractional Fix Points by Jorg Sommrey.
3. Perl Weekly Challenge 357: arrays everywhere! by Luca Ferrari.
4. One Constant, and Many Fractions by Matthias Muth.
5. I could drink a case of you… by Packy Anderson.
6. Converging on fractions by Peter Campbell Smith.
7. Uniquely Kaprekar by Roger Bell_West.
8. Fractional Constant by Simon Green.
GitHub Repository Stats
1. Commits: 47,502 (+111)
2. Pull Requests: 13,428 (+43)
3. Contributors: 273 (+1)
4. Fork: 350
5. Stars: 209
SPONSOR
We are looking for sponsor for monthly prize pot of US $50. 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 - 357 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
Alexander Goussas, an expert Haskell hacker joined 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 #357.
Please find past solutions by respected guests. Please share your creative solutions in other languages.
Task 1: Max Str Value
Submitted by: Mohammad Sajid Anwar
You are given an array of alphanumeric string, @strings.
Write a script to find the max value of alphanumeric string in the given array. The numeric representation of the string, if it comprises of digits only otherwise length of the string.
Example 1
Input: @strings = ("123", "45", "6")
Output: 123
"123" -> 123
"45" -> 45
"6" -> 6
Example 2
Input: @strings = ("abc", "de", "fghi")
Output: 4
"abc" -> 3
"de" -> 2
"fghi" -> 4
Example 3
Input: @strings = ("0012", "99", "a1b2c")
Output: 99
"0012" -> 12
"99" -> 99
"a1b2c" -> 5
Example 4
Input: @strings = ("x", "10", "xyz", "007")
Output: 10
"x" -> 1
"xyz" -> 3
"007" -> 7
"10" -> 10
Example 5
Input: @strings = ("hello123", "2026", "perl")
Output: 2026
"hello123" -> 8
"perl" -> 4
"2026" -> 2026
Task 2: Encrypted String
Submitted by: Mohammad Sajid Anwar
You are given a string $str and an integer $int.
Write a script to encrypt the string using the algorithm - for each character $char in $str, replace $char with the $int th character after $char in the alphabet, wrapping if needed and return the encrypted string.
Example 1
Input: $str = "abc", $int = 1
Output: "bcd"
Example 2
Input: $str = "xyz", $int = 2
Output: "zab"
Example 3
Input: $str = "abc", $int = 27
Output: "bcd"
Example 4
Input: $str = "hello", $int = 5
Output: "mjqqt"
Example 5
Input: $str = "perl", $int = 26
Output: "perl"
Last date to submit the solution 23:59 (UK Time) Sunday 1st February 2026.