From beb7abf2eb72adb99b7d83cfc84be0e73fcb1625 Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Sun, 13 Sep 2020 06:18:14 +0200 Subject: semicolons, comments, typos --- challenge-077/markus-holzer/raku/ch-1.raku | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/challenge-077/markus-holzer/raku/ch-1.raku b/challenge-077/markus-holzer/raku/ch-1.raku index 4f22b7501a..7337c6ca01 100644 --- a/challenge-077/markus-holzer/raku/ch-1.raku +++ b/challenge-077/markus-holzer/raku/ch-1.raku @@ -1,13 +1,22 @@ +# +# D:\Projekte\Perl6\perlweeklychallenge-club\challenge-077\markus-holzer\raku>raku ch-1.raku 123456789 +# Number of combinations: 3230 +# Calculated in 8.736 seconds +# +# Let me know if yours is faster +# See https://encyclopediaofmath.org/wiki/Zeckendorf_representation +# + use experimental :cached; unit sub MAIN( Int $N where * > 0, Bool :$v = False ); my $start = now; -with my @combinatons = gather combine zeckendorf $N +with my @combinations = gather combine zeckendorf $N { - say @combinatons.map( *.join( "," ) ).join( "\n" ) if $v; - say "# of combinations: {+@combinatons}"; + say @combinations.map( *.join( "," ) ).join( "\n" ) if $v; + say "Number of combinations: {+@combinations}"; say "Calculated in { sprintf "%.3f", now - $start } seconds" } @@ -34,7 +43,7 @@ sub zeckendorf( $n is copy ) is cached eager gather for @fib.grep( * < $n ).reverse { if $_ <= $n { take $_; - $n -= $_; }}} + $n -= $_ }}} $n == 1 ?? 1.List !! do-zeckendorf } \ No newline at end of file -- cgit