aboutsummaryrefslogtreecommitdiff
path: root/challenge-077/markus-holzer
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-09-13 06:18:14 +0200
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-09-13 06:18:14 +0200
commitbeb7abf2eb72adb99b7d83cfc84be0e73fcb1625 (patch)
treef0633a0d6c0a51b0962779dfe8678a9071b896fb /challenge-077/markus-holzer
parent1336e9d06871f76059da4f2b8f0c685d2042600f (diff)
downloadperlweeklychallenge-club-beb7abf2eb72adb99b7d83cfc84be0e73fcb1625.tar.gz
perlweeklychallenge-club-beb7abf2eb72adb99b7d83cfc84be0e73fcb1625.tar.bz2
perlweeklychallenge-club-beb7abf2eb72adb99b7d83cfc84be0e73fcb1625.zip
semicolons, comments, typos
Diffstat (limited to 'challenge-077/markus-holzer')
-rw-r--r--challenge-077/markus-holzer/raku/ch-1.raku17
1 files 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