diff options
| author | Markus "Holli" Holzer <holli.holzer@gmail.com> | 2020-04-13 20:11:12 +0200 |
|---|---|---|
| committer | Markus "Holli" Holzer <holli.holzer@gmail.com> | 2020-04-13 20:11:12 +0200 |
| commit | 8b041abbab4ca41387d94298a4b10ee0ab564870 (patch) | |
| tree | 29bef72753c683597137a45fda486d73e38ca347 | |
| parent | f07be68eed70fd308d35e5eea135ce70d2da7d29 (diff) | |
| download | perlweeklychallenge-club-8b041abbab4ca41387d94298a4b10ee0ab564870.tar.gz perlweeklychallenge-club-8b041abbab4ca41387d94298a4b10ee0ab564870.tar.bz2 perlweeklychallenge-club-8b041abbab4ca41387d94298a4b10ee0ab564870.zip | |
no need to carry the sum
| -rw-r--r-- | challenge-056/markus-holzer/raku/ch-2.p6 | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/challenge-056/markus-holzer/raku/ch-2.p6 b/challenge-056/markus-holzer/raku/ch-2.p6 index b184114a93..c08d41df1a 100644 --- a/challenge-056/markus-holzer/raku/ch-2.p6 +++ b/challenge-056/markus-holzer/raku/ch-2.p6 @@ -20,21 +20,21 @@ my %tree = .join('→').say for find-path-sum( %tree, 22 ); -multi sub find-path-sum( %t, $n ) +multi sub find-path-sum( %tree, $n ) { - gather find-path-sum( %t, 0, [], $n ); + gather find-path-sum( %tree, $n, [] ); } -multi sub find-path-sum( $tree, $sum, $path, $n ) +multi sub find-path-sum( $tree, $n, $path ) { for $tree.keys -> $k { my $p = $path.clone.push( $k ); - my $s = $sum + $k; + my $s = $path.sum + $k; if my $t = $tree{ $k } { - find-path-sum( $t, $s, $p, $n ); + find-path-sum( $t, $n, $p ); next; } |
