diff options
| -rw-r--r-- | challenge-077/markus-holzer/raku/ch-1.raku | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/challenge-077/markus-holzer/raku/ch-1.raku b/challenge-077/markus-holzer/raku/ch-1.raku index 054dd51cb9..44b5af60d4 100644 --- a/challenge-077/markus-holzer/raku/ch-1.raku +++ b/challenge-077/markus-holzer/raku/ch-1.raku @@ -6,37 +6,37 @@ my $start = now; with my @combinatons = gather combine zeckendorf $N { - say @combinatons.map( *.join( "," ) ).join( "\n" ) if $v; - say "# of combinations: {+@combinatons}"; - say "Calculated in { sprintf "%.3f", now - $start } seconds" + say @combinatons.map( *.join( "," ) ).join( "\n" ) if $v; + say "# of combinations: {+@combinatons}"; + say "Calculated in { sprintf "%.3f", now - $start } seconds" } sub combine( @Z ) is cached { - my &valid = -> $result { - $result.elems == $result.unique.elems && $result !~~ @Z }; + my &valid = -> $result { + $result.elems == $result.unique.elems && $result !~~ @Z }; - my &insert = -> $where, $what { - my @x = @Z.clone; @x.splice( $where, 1, |$what ); @x }; + my &insert = -> $where, $what { + my @x = @Z.clone; @x.splice( $where, 1, |$what ); @x }; - take @Z; + take @Z; - sink @Z - .map( &zeckendorf ) - .kv.map( &insert ) - .grep( &valid ) - .map( &combine ) + sink @Z + .map( &zeckendorf ) + .kv.map( &insert ) + .grep( &valid ) + .map( &combine ) } sub zeckendorf( $n is copy ) is cached { - state @fib = [1, 1, * + * ... * > $N]; + state @fib = [1, 1, * + * ... * > $N]; - my &do-zeckendorf = { - eager gather for @fib.grep( * < $n ).reverse { - if $_ <= $n { - take $_; - $n -= $_; }}} + my &do-zeckendorf = { + eager gather for @fib.grep( * < $n ).reverse { + if $_ <= $n { + take $_; + $n -= $_; }}} - $n == 1 ?? 1.List !! do-zeckendorf + $n == 1 ?? 1.List !! do-zeckendorf }
\ No newline at end of file |
