aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;