aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-02-21 17:08:50 +0000
committerGitHub <noreply@github.com>2022-02-21 17:08:50 +0000
commitd249ad00c150df69f22054bc493149fc9f7c7852 (patch)
treeee35b64d91f14716c713a349f630a2bc62e7cf68
parentcfca3722c03e00ce0a3fc650def01e6d102dcb3b (diff)
parentfa79f4e07e46cabac7610d2582e77f897d2db55c (diff)
downloadperlweeklychallenge-club-d249ad00c150df69f22054bc493149fc9f7c7852.tar.gz
perlweeklychallenge-club-d249ad00c150df69f22054bc493149fc9f7c7852.tar.bz2
perlweeklychallenge-club-d249ad00c150df69f22054bc493149fc9f7c7852.zip
Merge pull request #5691 from fluca1978/PWC153
Pwc153
-rw-r--r--challenge-153/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-153/luca-ferrari/blog-2.txt1
-rwxr-xr-xchallenge-153/luca-ferrari/raku/ch-1.p620
-rwxr-xr-xchallenge-153/luca-ferrari/raku/ch-2.p66
4 files changed, 28 insertions, 0 deletions
diff --git a/challenge-153/luca-ferrari/blog-1.txt b/challenge-153/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..774fb793c5
--- /dev/null
+++ b/challenge-153/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2022/02/21/PerlWeeklyChallenge153.html#task1
diff --git a/challenge-153/luca-ferrari/blog-2.txt b/challenge-153/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..06b4f03159
--- /dev/null
+++ b/challenge-153/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2022/02/21/PerlWeeklyChallenge153.html#task2
diff --git a/challenge-153/luca-ferrari/raku/ch-1.p6 b/challenge-153/luca-ferrari/raku/ch-1.p6
new file mode 100755
index 0000000000..801a647bd3
--- /dev/null
+++ b/challenge-153/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,20 @@
+#!raku
+
+sub MAIN( Int $limit where { $limit > 0 } = 10 ) {
+ my @factorials = lazy gather {
+ for 0 .. $limit {
+ take 1 if $_ <= 1;
+ take [*] 1 .. $_ if $_ > 1;
+ }
+ };
+
+ my @numbers = lazy gather {
+ for 0 .. $limit {
+ take 0 if $_ == 0;
+ take 1 if $_ == 1;
+ take @factorials[ 0 .. $_ -1 ].sum if $_ > 1;
+ }
+ };
+
+ @numbers[ 0 .. $limit ].join( "\n" ).say;
+}
diff --git a/challenge-153/luca-ferrari/raku/ch-2.p6 b/challenge-153/luca-ferrari/raku/ch-2.p6
new file mode 100755
index 0000000000..c7a04e83c5
--- /dev/null
+++ b/challenge-153/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,6 @@
+#!raku
+
+sub MAIN( Int $n where { $n > 0 } ) {
+ '1'.say and exit if $n.comb.map( { $_ <= 1 ?? 1 !! [*] 1 .. $_ } ).sum == $n;
+ '0'.say;
+}