diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-10-26 04:18:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-26 04:18:44 +0100 |
| commit | 6a24cd9d45f97e694a14810c142c9ec12edfd9f4 (patch) | |
| tree | 011d693179ac817243b6c098becf7c656dffe6bb | |
| parent | 764178eaa9a5411c4ffb10c57a038cf0870d2a27 (diff) | |
| parent | 2d5b702c9a348f2226fca9c981f0054c485aa1dd (diff) | |
| download | perlweeklychallenge-club-6a24cd9d45f97e694a14810c142c9ec12edfd9f4.tar.gz perlweeklychallenge-club-6a24cd9d45f97e694a14810c142c9ec12edfd9f4.tar.bz2 perlweeklychallenge-club-6a24cd9d45f97e694a14810c142c9ec12edfd9f4.zip | |
Merge pull request #5098 from fluca1978/pwc136
Pwc136
| -rw-r--r-- | challenge-136/luca-ferrari/blog-1.txt | 1 | ||||
| -rw-r--r-- | challenge-136/luca-ferrari/blog-2.txt | 1 | ||||
| -rwxr-xr-x | challenge-136/luca-ferrari/raku/ch-1.p6 | 5 | ||||
| -rwxr-xr-x | challenge-136/luca-ferrari/raku/ch-2.p6 | 28 |
4 files changed, 35 insertions, 0 deletions
diff --git a/challenge-136/luca-ferrari/blog-1.txt b/challenge-136/luca-ferrari/blog-1.txt new file mode 100644 index 0000000000..0e141f1428 --- /dev/null +++ b/challenge-136/luca-ferrari/blog-1.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2021/10/25/PerlWeeklyChallenge136.html#task1 diff --git a/challenge-136/luca-ferrari/blog-2.txt b/challenge-136/luca-ferrari/blog-2.txt new file mode 100644 index 0000000000..99f4aed91f --- /dev/null +++ b/challenge-136/luca-ferrari/blog-2.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2021/10/25/PerlWeeklyChallenge136.html#task2 diff --git a/challenge-136/luca-ferrari/raku/ch-1.p6 b/challenge-136/luca-ferrari/raku/ch-1.p6 new file mode 100755 index 0000000000..aa3bf36984 --- /dev/null +++ b/challenge-136/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,5 @@ +#!raku + +sub MAIN( Int $m where { $m > 0 }, Int $n where { $n > 0 } ) { + ( [gcd] $m, $n ) %% 2 ?? '1'.say !! '0'.say; +} diff --git a/challenge-136/luca-ferrari/raku/ch-2.p6 b/challenge-136/luca-ferrari/raku/ch-2.p6 new file mode 100755 index 0000000000..6a606785ee --- /dev/null +++ b/challenge-136/luca-ferrari/raku/ch-2.p6 @@ -0,0 +1,28 @@ +#!raku + +sub MAIN( Int $n where { $n > 1 } ) { + # my @fibonacci; + # @fibonacci.push: 1, 1; + # my %solutions; + + # # compute a reduced fibonacci sequence up to the sum of the number given + # @fibonacci.push: @fibonacci[ * - 1 ] + @fibonacci[ * - 2 ] while $n > ( @fibonacci[ * - 1] + @fibonacci[ * - 2 ]); + + + # # iterate over all the available numbers, and compute the sum + # # and if the sum does match, add the array to the hash of solutions + # # with a stringified key representation + # %solutions{ $_.join( ' + ') } = $_ if ( ( [+] $_ ) == $n ) for @fibonacci.combinations.unique; + + # # print the number of keys + # say %solutions.keys.elems; + # # and print all the sums + # .join( " + " ).say for %solutions.values; + + + my @fibonacci = 1, 1, * + * ... * > $n; + my @solutions = @fibonacci.unique.combinations.grep( *.sum == $n ); + @solutions.elems.say; + .join( ' + ' ).say for @solutions; + +} |
