diff options
| author | Abigail <abigail@abigail.be> | 2021-08-15 17:59:44 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-08-15 17:59:44 +0200 |
| commit | 34aa316cdbeb0e57f530089e366856b7f86b72cc (patch) | |
| tree | 3794c2504c93edfbd4eb4d900c2f384482b48f6b /challenge-125 | |
| parent | 26018e17bb38f61027306864c9b9a63063b7f089 (diff) | |
| download | perlweeklychallenge-club-34aa316cdbeb0e57f530089e366856b7f86b72cc.tar.gz perlweeklychallenge-club-34aa316cdbeb0e57f530089e366856b7f86b72cc.tar.bz2 perlweeklychallenge-club-34aa316cdbeb0e57f530089e366856b7f86b72cc.zip | |
Fix calculation of diameter passing through root
Diffstat (limited to 'challenge-125')
| -rw-r--r-- | challenge-125/abigail/perl/ch-2.pl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/challenge-125/abigail/perl/ch-2.pl b/challenge-125/abigail/perl/ch-2.pl index 29d0c71c02..45806530f7 100644 --- a/challenge-125/abigail/perl/ch-2.pl +++ b/challenge-125/abigail/perl/ch-2.pl @@ -65,12 +65,12 @@ package Tree { # # Depth of a tree is 1 + max (depth left child, depth right child) # Diameter of a tree is max (diameter left child, - # diameter right child, 1 + depth left child + depth right child). + # diameter right child, depth left child + depth right child). # return (0, 0) unless $self; # Leaves have no depth nor diameter. my ($ldp, $ldm) = $self -> left -> _diameter; my ($rdp, $rdm) = $self -> right -> _diameter; - (max ($ldp, $rdp), max ($ldm, $rdm, 1 + $ldp + $rdp)) + (max ($ldp, $rdp), max ($ldm, $rdm, $ldp + $rdp)) } } |
