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: Pythagorean Triples
10. TASK #2: Binary Tree Diameter
HEADLINES
Welcome to the 125
th edition of the weekly challenge.
I would like to thank every Team PWC members for sharing fun tasks. It is a big help and reduce my work load. So please keep sending new challenges.
Last week, we had new member, Peter Campbell Smith
, an experienced Perl hacker from Epsom, UK joining the Team PWC.
We also had the first Raku Conference last week. One of our Team PWC member, Andrew Shitov
, gave an interesting presentation talking about Raku contributions. It was great to be discussed on such a big platform. I also had the opportunity to give a short talk (30 minutes) about Making of Raku Developer on Day 3. If you missed the event then I would highly recommend you watch the recordings available on YouTube.
Let us share some interesting stats from the GitHub repository.
1. Commits: 19,096 (+164)
2. Pull Requests: 4,681 (+40)
3. Contributors: 173 (+2)
4. Fork: 219 (+1)
5. Stars: 98 (+1)
Last but not least, I would like to thank each and every member for their support and encouragement.
SPONSOR
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 2021. 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 2021. 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 - 124” by Mohammad S Anwar
.
PERL REVIEW
Please check out Perl solutions review of the “The Weekly Challenge - 122” by Colin Crain
.
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
Peter Campbell Smith, an experienced Perl hacker from Epsom, UK 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 checkout the guest contributions for the Week #124.
Please find past solutions by respected guests. Please share your creative solutions in other languages.
TASK #1 › Pythagorean Triples
Submitted by: Cheok-Yin Fung
You are given a positive integer $N
.
Write a script to print all Pythagorean Triples
containing $N
as a member. Print -1 if it can’t be a member of any. i
Triples with the same set of elements are considered the same, i.e. if your script has already printed (3, 4, 5), (4, 3, 5) should not be printed.
The famous Pythagorean theorem states that in a right angle triangle, the length of the two shorter sides and the length of the longest side are related by a2+b2 = c2.
A Pythagorean triple refers to the triple of three integers whose lengths can compose a right-angled triangle.
Example
Input: $N = 5
Output:
(3, 4, 5)
(5, 12, 13)
Input: $N = 13
Output:
(5, 12, 13)
(13, 84, 85)
Input: $N = 1
Output:
-1
TASK #2 › Binary Tree Diameter
Submitted by: Mohammad S Anwar
You are given binary tree as below:
1
/ \
2 5
/ \ / \
3 4 6 7
/ \
8 10
/
9
Write a script to find the diameter of the given binary tree.
The diameter of a binary tree is the length of the longest path between any two nodes in a tree. It doesn’t have to pass through the root.
For the above given binary tree, possible diameters (6) are:
3, 2, 1, 5, 7, 8, 9
or
4, 2, 1, 5, 7, 8, 9
UPDATE (2021-08-10 17:00:00 BST): Jorg Sommrey corrected the example.
The length of a path is the number of its edges, not the number of the vertices it connects. So the diameter should be 6, not 7.
Last date to submit the solution 23:59 (UK Time) Sunday 15th August 2021.