Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Try to fix balanced tree test
not quite right, but at least it doesn't abort anymore
  • Loading branch information
moritz committed Aug 26, 2015
1 parent dca7f19 commit 978df96
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions integration/99problems-51-to-60.t
Expand Up @@ -59,27 +59,27 @@ plan 37;
my $k = ($n - 1) div 2;
for cbal-tree($k) -> $a {
for cbal-tree($k) -> $b {
take ['x', $a, $b];
take ['x', $a, $b],;
}
}
} else {
my $k = $n div 2;
for cbal-tree($k) -> $a {
for cbal-tree($k - 1) -> $b {
take ['x', $a, $b];
take ['x', $a, $b],;
}
}
for cbal-tree($k - 1) -> $a {
for cbal-tree($k) -> $b {
take ['x', $a, $b];
take ['x', $a, $b],;
}
}
}
}
}

is-deeply [ cbal-tree(1) ],
[['x', Any, Any]],
[['x', Any, Any],],
'built a balanced binary tree with 1 item';

is-deeply [ cbal-tree(2) ],
Expand Down Expand Up @@ -243,17 +243,17 @@ plan 37;
}

sub hbal-tree(Int $n) {
return Mu if $n == 0;
return ['x', Mu, Mu] if $n == 1;
return Any if $n == 0;
return(['x', Any, Any],) if $n == 1;
gather {
for hbal-tree($n - 1) -> $a {
for hbal-tree($n - 1) -> $b {
take ['x', $a, $b];
take ['x', $a, $b],;
}
for hbal-tree($n - 2) -> $b {
if is-hbal(['x', $a, $b]) {
take ['x', $a, $b];
take ['x', $b, $a];
take ['x', $a, $b],;
take ['x', $b, $a],;
}
}
}
Expand Down

0 comments on commit 978df96

Please sign in to comment.