aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark <53903062+andemark@users.noreply.github.com>2022-02-07 17:21:38 +0000
committerMark <53903062+andemark@users.noreply.github.com>2022-02-07 17:21:38 +0000
commit512732b7f20ab5fc2f32dd307092bb82b58c97e1 (patch)
tree0b0c36704473063f73f3ed9cb6526c5603721760
parenta1bf165258539b0aa7117dbfebce87aae1f60cd3 (diff)
downloadperlweeklychallenge-club-512732b7f20ab5fc2f32dd307092bb82b58c97e1.tar.gz
perlweeklychallenge-club-512732b7f20ab5fc2f32dd307092bb82b58c97e1.tar.bz2
perlweeklychallenge-club-512732b7f20ab5fc2f32dd307092bb82b58c97e1.zip
initial 151
-rw-r--r--challenge-151/mark-anderson/raku/ch-1.raku7
1 files changed, 4 insertions, 3 deletions
diff --git a/challenge-151/mark-anderson/raku/ch-1.raku b/challenge-151/mark-anderson/raku/ch-1.raku
index 21d3f470ac..4797264da4 100644
--- a/challenge-151/mark-anderson/raku/ch-1.raku
+++ b/challenge-151/mark-anderson/raku/ch-1.raku
@@ -4,14 +4,15 @@ use Test;
is binary-tree-depth('1 | 2 3 | 4 5'), 2;
is binary-tree-depth('1 | 2 3 | 4 * * 5 | * 6'), 3;
+is binary-tree-depth('1 | 2 3 | 4 * * 5 | 6 * * 7 | 8 * * 9 | 10 *'), 5;
-sub binary-tree-depth($tree)
+sub binary-tree-depth($str)
{
- my @tree = $tree.split(/\s\|\s/).map(*.split(/\s/));
+ my $tree := $str.split(/\s\|\s/).map(*.split(/\s/));
my $elems = 1;
my $depth = 0;
- for @tree -> $nodes
+ for $tree -> $nodes
{
last unless $nodes.elems == $elems;
$elems = ($elems - $nodes.comb('*')) * 2;