aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-01-25 19:06:49 +0000
committerGitHub <noreply@github.com>2021-01-25 19:06:49 +0000
commit1a729de6e58f6962990e16ad1547a5c46b7b84d9 (patch)
treead90247dec236c0a0a17818f1a80dae4f8a45105
parent72106712589cb057d437660b63a0a8b5cabf4ae3 (diff)
parentbc316f079156db9bae4a5001342bb91f819ca4ec (diff)
downloadperlweeklychallenge-club-1a729de6e58f6962990e16ad1547a5c46b7b84d9.tar.gz
perlweeklychallenge-club-1a729de6e58f6962990e16ad1547a5c46b7b84d9.tar.bz2
perlweeklychallenge-club-1a729de6e58f6962990e16ad1547a5c46b7b84d9.zip
Merge pull request #3372 from fluca1978/pwc97
Pwc97
-rw-r--r--challenge-097/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-097/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-097/luca-ferrari/raku/ch-1.p620
-rw-r--r--challenge-097/luca-ferrari/raku/ch-2.p620
4 files changed, 42 insertions, 0 deletions
diff --git a/challenge-097/luca-ferrari/blog-1.txt b/challenge-097/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..97c76f94e4
--- /dev/null
+++ b/challenge-097/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/01/25/PerlWeeklyChallenge97.html#task1
diff --git a/challenge-097/luca-ferrari/blog-2.txt b/challenge-097/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..e195e7432a
--- /dev/null
+++ b/challenge-097/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/01/25/PerlWeeklyChallenge97.html#task2
diff --git a/challenge-097/luca-ferrari/raku/ch-1.p6 b/challenge-097/luca-ferrari/raku/ch-1.p6
new file mode 100644
index 0000000000..483797f301
--- /dev/null
+++ b/challenge-097/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,20 @@
+#!raku
+
+
+sub MAIN( Str $S = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG",
+ Int $N where { $N > 0 && $N < ( 'A' .. 'Z' ).elems } = 3 ) {
+ my @alphabet = 'A' .. 'Z';
+ my %cipher;
+ # my $index = @alphabet.elems - $N;
+ # for @alphabet {
+ # %cipher{ $_ } = @alphabet[ $index ];
+ # $index = $index + 1 < @alphabet.elems ?? $index + 1 !! 0 ;
+ # }
+
+ %cipher{ @alphabet[ $_ ] } = @alphabet.rotate( $N * -1 )[ $_ ] for ^@alphabet.elems;
+
+ my @encoded;
+ @encoded.push: %cipher{ $_ }:exists ?? %cipher{ $_ } !! $_ for $S.uc.comb;
+ # "Encoded string for text\n$S\nis\n{ @encoded.join('') }\n".say
+ @encoded.join.say;
+}
diff --git a/challenge-097/luca-ferrari/raku/ch-2.p6 b/challenge-097/luca-ferrari/raku/ch-2.p6
new file mode 100644
index 0000000000..7746228800
--- /dev/null
+++ b/challenge-097/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,20 @@
+#!raku
+
+
+sub MAIN( Str $B = "101100101",
+ Int $S = 3 ) {
+
+ my @splits = $B.comb: $S.Int;
+ my $flips = 0;
+
+ my ( $a, $b ) = @splits[ 0 ], Nil;
+
+ for 1 ..^ @splits.elems {
+ $b = @splits[ $_ ];
+
+ # find out how many chars are different
+ $flips++ if ( $a.comb[ $_ ] != $b.comb[ $_ ] ) for ^@$a.comb.elems;
+ }
+
+ say $flips;
+}