aboutsummaryrefslogtreecommitdiff
path: root/challenge-094
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-10-22 16:23:23 +0100
committerPaulo Custodio <pauloscustodio@gmail.com>2021-10-25 10:20:30 +0100
commit9b6c375110f64e808302a72de1d63c41b1fd56b7 (patch)
treeabb09a2ea02bc5ceac95539fe6429972f2e2331c /challenge-094
parent9af4627df80018091f1bbf86c07ede1eeeb6548f (diff)
downloadperlweeklychallenge-club-9b6c375110f64e808302a72de1d63c41b1fd56b7.tar.gz
perlweeklychallenge-club-9b6c375110f64e808302a72de1d63c41b1fd56b7.tar.bz2
perlweeklychallenge-club-9b6c375110f64e808302a72de1d63c41b1fd56b7.zip
Add Perl and Python solutions to challenge 130
Diffstat (limited to 'challenge-094')
-rw-r--r--challenge-094/paulo-custodio/perl/ch-2.pl9
1 files changed, 6 insertions, 3 deletions
diff --git a/challenge-094/paulo-custodio/perl/ch-2.pl b/challenge-094/paulo-custodio/perl/ch-2.pl
index 3ca9551cb4..fccddc0ebc 100644
--- a/challenge-094/paulo-custodio/perl/ch-2.pl
+++ b/challenge-094/paulo-custodio/perl/ch-2.pl
@@ -47,7 +47,7 @@ sub parse_tree {
chomp(my @lines = <>);
@lines or die "malformed tree\n";
$lines[0] =~ /^( +)\d/ or die "malformed tree\n";
- $tree = parse_subtree(\@lines, 0, length($1));
+ my $tree = parse_subtree(\@lines, 0, length($1));
return $tree;
}
@@ -62,12 +62,15 @@ sub parse_subtree {
# parse children
if ($row+2 <= $#{$lines}) {
# parse left subtree
- if ($col-2 >= 0 && $col-2 < length($lines->[$row+1]) && substr($lines->[$row+1], $col-1, 1) eq '/') {
+ if ($col-2 >= 0 &&
+ $col-2 < length($lines->[$row+1]) &&
+ substr($lines->[$row+1], $col-1, 1) eq '/') {
my $child = parse_subtree($lines, $row+2, $col-2);
$node->left($child);
}
# parse right subtree
- if ($col+2 < length($lines->[$row+2]) && substr($lines->[$row+1], $col+1, 1) eq '\\') {
+ if ($col+2 < length($lines->[$row+2]) &&
+ substr($lines->[$row+1], $col+1, 1) eq '\\') {
my $child = parse_subtree($lines, $row+2, $col+2);
$node->right($child);
}