aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-02-08 06:31:11 +0100
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-02-08 06:31:11 +0100
commit6e3ffc32e2c3e4ebff49d101e21ff79b2ab29695 (patch)
tree0bb55dbdc9710cf3381cb4530bb898479579353a
parentc35740ed11245d31ffe39492774600cb1abf065d (diff)
parent90ba2a3e9be09c64ed20d58b0145668dafb22d11 (diff)
downloadperlweeklychallenge-club-6e3ffc32e2c3e4ebff49d101e21ff79b2ab29695.tar.gz
perlweeklychallenge-club-6e3ffc32e2c3e4ebff49d101e21ff79b2ab29695.tar.bz2
perlweeklychallenge-club-6e3ffc32e2c3e4ebff49d101e21ff79b2ab29695.zip
Merge remote-tracking branch 'upstream/master'
-rw-r--r--challenge-042/roger-bell-west/blog.txt1
-rw-r--r--challenge-045/kevin-colyer/raku/ch-1.p666
-rw-r--r--challenge-045/kevin-colyer/raku/ch-2.p618
-rw-r--r--challenge-046/alicia-bielsa/perl/ch-1.pl55
-rw-r--r--challenge-046/alicia-bielsa/perl/ch-2.pl32
-rw-r--r--challenge-046/andrezgz/perl/ch-1.pl57
-rw-r--r--challenge-046/andrezgz/perl/ch-2.pl36
-rw-r--r--challenge-046/arne-sommer/blog.txt1
-rwxr-xr-xchallenge-046/arne-sommer/raku/ch-1.p623
-rwxr-xr-xchallenge-046/arne-sommer/raku/ch-2.p619
-rwxr-xr-xchallenge-046/arne-sommer/raku/cryptic49
-rwxr-xr-xchallenge-046/arne-sommer/raku/cryptic-simple23
-rwxr-xr-xchallenge-046/arne-sommer/raku/room50019
-rwxr-xr-xchallenge-046/arne-sommer/raku/room500-infseq5
-rwxr-xr-xchallenge-046/arne-sommer/raku/room500-loop22
-rwxr-xr-xchallenge-046/arne-sommer/raku/room500-seq5
-rw-r--r--challenge-046/cristian-heredia/perl/ch-1.pl47
-rw-r--r--challenge-046/cristian-heredia/perl/ch-2.pl45
-rw-r--r--challenge-046/dave-jacoby/perl/ch-1.pl50
-rw-r--r--challenge-046/dave-jacoby/perl/ch-2.pl35
-rwxr-xr-xchallenge-046/duane-powell/perl/ch-1.pl56
-rwxr-xr-xchallenge-046/duane-powell/perl/ch-2.pl52
-rw-r--r--challenge-046/duncan-c-white/README60
-rwxr-xr-xchallenge-046/duncan-c-white/perl/ch-1.pl79
-rwxr-xr-xchallenge-046/duncan-c-white/perl/ch-2.pl61
-rw-r--r--challenge-046/duncan-c-white/postscript/ch-2.ps192
-rwxr-xr-xchallenge-046/e-choroba/perl/ch-1.pl22
-rwxr-xr-xchallenge-046/e-choroba/perl/ch-2.pl13
-rwxr-xr-xchallenge-046/e-choroba/perl/ch-2a.pl9
-rwxr-xr-xchallenge-046/e-choroba/perl/ch-2b.pl6
-rw-r--r--challenge-046/javier-luque/blog.txt1
-rw-r--r--challenge-046/javier-luque/perl/ch-1.pl39
-rw-r--r--challenge-046/javier-luque/perl/ch-2.pl20
-rw-r--r--challenge-046/javier-luque/raku/ch-1.p639
-rw-r--r--challenge-046/javier-luque/raku/ch-2.p619
-rw-r--r--challenge-046/kevin-colyer/raku/ch-1.p666
-rw-r--r--challenge-046/kevin-colyer/raku/ch-2.p630
-rw-r--r--challenge-046/luca-ferrari/blog.txt1
-rw-r--r--challenge-046/luca-ferrari/raku/ch-1.p6111
-rw-r--r--challenge-046/luca-ferrari/raku/ch-2.p658
-rw-r--r--challenge-046/mark-anderson/raku/ch-2.p624
-rw-r--r--challenge-046/markus-holzer/raku/ch-1.p6 (renamed from challenge-046/markus-holzer/raku/ch-1.raku)0
-rw-r--r--challenge-046/markus-holzer/raku/ch-2.p6 (renamed from challenge-046/markus-holzer/raku/ch-2.raku)0
-rw-r--r--challenge-046/orestis-zekai/python/ch-1.py14
-rw-r--r--challenge-046/orestis-zekai/python/ch-2.py19
-rwxr-xr-xchallenge-046/peter-scott/perl/ch-2.sh3
-rw-r--r--challenge-046/rage311/perl/ch-1.pl48
-rw-r--r--challenge-046/rage311/perl/ch-2.pl25
-rw-r--r--challenge-046/roger-bell-west/input15
-rw-r--r--challenge-046/roger-bell-west/input26
-rwxr-xr-xchallenge-046/roger-bell-west/perl/ch-1.pl19
-rwxr-xr-xchallenge-046/roger-bell-west/perl/ch-2.pl14
-rwxr-xr-xchallenge-046/roger-bell-west/raku/ch-1.p616
-rwxr-xr-xchallenge-046/roger-bell-west/raku/ch-2.p611
-rw-r--r--challenge-046/ruben-westerberg/README5
-rwxr-xr-xchallenge-046/ruben-westerberg/perl/ch-1.pl27
-rwxr-xr-xchallenge-046/ruben-westerberg/perl/ch-2.pl14
-rwxr-xr-xchallenge-046/ruben-westerberg/raku/ch-1.p617
-rwxr-xr-xchallenge-046/ruben-westerberg/raku/ch-2.p611
-rw-r--r--challenge-046/ryan-thompson/README.md19
-rw-r--r--challenge-046/ryan-thompson/blog.txt1
-rw-r--r--challenge-046/ryan-thompson/blog1.txt1
-rwxr-xr-xchallenge-046/ryan-thompson/perl/ch-1.pl35
-rwxr-xr-xchallenge-046/ryan-thompson/perl/ch-2.pl25
-rwxr-xr-xchallenge-046/ryan-thompson/raku/ch-1.p643
-rwxr-xr-xchallenge-046/ryan-thompson/raku/ch-2.p621
-rw-r--r--challenge-046/saiftynet/perl/ch-1.pl118
-rw-r--r--challenge-046/saiftynet/perl/ch-2.pl47
-rw-r--r--challenge-046/simon-proctor/raku/ch-1.p624
-rw-r--r--challenge-046/simon-proctor/raku/ch-2.p615
-rw-r--r--challenge-046/ulrich-rieke/cpp/ch-1.cpp29
-rw-r--r--challenge-046/ulrich-rieke/cpp/ch-2.cpp39
-rw-r--r--challenge-046/ulrich-rieke/haskell/ch-1.hs16
-rw-r--r--challenge-046/ulrich-rieke/perl/ch-1.pl25
-rw-r--r--challenge-046/ulrich-rieke/perl/ch-2.pl33
-rw-r--r--challenge-046/ulrich-rieke/raku/ch-1.p623
-rw-r--r--challenge-046/ulrich-rieke/raku/ch-2.p621
-rw-r--r--challenge-046/wanderdoc/perl/ch-1.pl87
-rw-r--r--challenge-046/wanderdoc/perl/ch-2.pl82
-rw-r--r--stats/pwc-challenge-042.json470
-rw-r--r--stats/pwc-challenge-045.json634
-rw-r--r--stats/pwc-current.json553
-rw-r--r--stats/pwc-language-breakdown-summary.json68
-rw-r--r--stats/pwc-language-breakdown.json671
-rw-r--r--stats/pwc-leaders.json856
-rw-r--r--stats/pwc-summary-1-30.json48
-rw-r--r--stats/pwc-summary-121-150.json36
-rw-r--r--stats/pwc-summary-31-60.json56
-rw-r--r--stats/pwc-summary-61-90.json106
-rw-r--r--stats/pwc-summary-91-120.json56
-rw-r--r--stats/pwc-summary.json108
91 files changed, 4547 insertions, 1639 deletions
diff --git a/challenge-042/roger-bell-west/blog.txt b/challenge-042/roger-bell-west/blog.txt
new file mode 100644
index 0000000000..c10d17d6f2
--- /dev/null
+++ b/challenge-042/roger-bell-west/blog.txt
@@ -0,0 +1 @@
+https://blog.firedrake.org/archive/2020/02/Perl_Weekly_Challenge_42__octal_and_balancing_brackets.html
diff --git a/challenge-045/kevin-colyer/raku/ch-1.p6 b/challenge-045/kevin-colyer/raku/ch-1.p6
new file mode 100644
index 0000000000..cd80cf7cad
--- /dev/null
+++ b/challenge-045/kevin-colyer/raku/ch-1.p6
@@ -0,0 +1,66 @@
+#!/usr/bin/perl6
+use v6;
+
+use Test;
+
+
+=begin pod
+
+TASK #1
+Square Secret Code
+The squate secret code mechanism first removes any space from the original message. Then it lays down the message in a row of 8 columns. The coded message is then obtained by reading down the columns going left to right.
+
+For example, the message is “The quick brown fox jumps over the lazy dog”.
+
+Then the message would be laid out as below:
+
+thequick
+brownfox
+jumpsove
+rthelazy
+dog
+The code message would be as below:
+
+tbjrd hruto eomhg qwpe unsl ifoa covz kxey
+
+Write a script that accepts a message from command line and prints the equivalent coded message.
+
+
+=end pod
+
+multi MAIN(Str $plaintext) {
+ squareSecretEncode($plaintext).say
+}
+
+multi MAIN('test') {
+ is squareSecretEncode("The quick brown fox jumps over the lazy dog"),"tbjrd hruto eomhg qwpe unsl ifoa covz kxey","Encodes correctly";
+ done-testing;
+}
+
+sub squareSecretEncode(Str $plaintext) returns Str {
+ # transform to lowercase a-z only and remove spaces then split
+ my @t=$plaintext.lc.trans(['a'..'z'] => '', :complement).comb;
+ # calculate the rows in the 8x? grid
+ my $rows=(@t.elems + 8) div 8;
+
+ # gather the ciphered text - go over entire grid even though it may not fill entirely
+ my @c=gather for ^$rows*8 -> $i {
+ # transform the left to right array traversal to a down first then along
+ # DOWN ALONG
+ my $j=($i % $rows)*8 + $i div $rows;
+
+ # if we are over the end of the array take a space and loop
+ # could avoid this code if we add 8 spaces to end of array...
+ if $j>=@t.elems {
+ take " ";
+ next
+ };
+
+ # take the element at the translated position
+ take @t[$j];
+ }
+ # make a string from @c using rotor to combine every 5 elements (or less at end)...
+ # join the new list of 5 elems to a string...
+ # as the new string might have a space split on words and re-join with single space
+ ~@c.rotor(5,:partial)>>.join>>.words>>.join(" ");
+}
diff --git a/challenge-045/kevin-colyer/raku/ch-2.p6 b/challenge-045/kevin-colyer/raku/ch-2.p6
new file mode 100644
index 0000000000..8ad73f6dcd
--- /dev/null
+++ b/challenge-045/kevin-colyer/raku/ch-2.p6
@@ -0,0 +1,18 @@
+#!/usr/bin/perl6
+use v6;
+
+=begin pod
+
+TASK #2
+Source Dumper
+Write a script that dumps its own source code. For example, say, the script name is ch-2.pl then the following command should returns nothing.
+
+$ perl ch-2.pl | diff - ch-2.pl
+
+
+=end pod
+
+# $*PROGRAM has the IO.Path object of the program. I use print as this keeps the same number
+# of new lines as in the source (.say would add an extra one)
+slurp($*PROGRAM).print;
+
diff --git a/challenge-046/alicia-bielsa/perl/ch-1.pl b/challenge-046/alicia-bielsa/perl/ch-1.pl
new file mode 100644
index 0000000000..e2ff41d1b4
--- /dev/null
+++ b/challenge-046/alicia-bielsa/perl/ch-1.pl
@@ -0,0 +1,55 @@
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+#Cryptic Message
+#The communication system of an office is broken and message received are not completely reliable. To send message Hello, it ended up sending these following:
+#
+#H x l 4 !
+#c e - l o
+#z e 6 l g
+#H W l v R
+#q 9 m # o
+#Similary another day we received a message repeatedly like below:
+#
+#P + 2 l ! a t o
+#1 e 8 0 R $ 4 u
+#5 - r ] + a > /
+#P x w l b 3 k \
+#2 e 3 5 R 8 y u
+#< ! r ^ ( ) k 0
+#Write a script to decrypt the above repeated message (one message repeated 6 times).
+#
+#HINT: Look for characters repeated in a particular position in all six messages received.
+
+my @aMessage1 = qw(P + 2 l ! a t o);
+my @aMessage2 = qw(1 e 8 0 R $ 4 u);
+my @aMessage3 = qw(5 - r ] + a > /);
+my @aMessage4 = qw(P x w l b 3 k \\);
+my @aMessage5 = qw(2 e 3 5 R 8 y u);
+my @aMessage6 = qw(< ! r ^ ( ) k 0);
+my @aCharactersRepeated = ();
+my $lengthMessage = scalar(@aMessage1);
+my @aAllMessages = (@aMessage1, @aMessage2 ,@aMessage3, @aMessage4, @aMessage5 ,@aMessage6);
+my %hCharacters = ();
+
+foreach my $indexAllMesages (0..$#aAllMessages){
+ my $indexMessage = $indexAllMesages % $lengthMessage;
+ my $currentCharacter = $aAllMessages[$indexAllMesages];
+ unless (exists($hCharacters{$indexMessage})){
+ $hCharacters{$indexMessage} =();
+ }
+ unless (exists($hCharacters{$indexMessage}{$currentCharacter})){
+ $hCharacters{$indexMessage}{$currentCharacter} = 0 ;
+ }
+ $hCharacters{$indexMessage}{$currentCharacter} ++;
+ if ($hCharacters{$indexMessage}{$currentCharacter} == 2 ){
+ $aCharactersRepeated[$indexMessage] = $currentCharacter;
+ }
+}
+print "Decrypted Message:";
+foreach my $character (@aCharactersRepeated){
+ print "$character";
+}
+print "\n";
diff --git a/challenge-046/alicia-bielsa/perl/ch-2.pl b/challenge-046/alicia-bielsa/perl/ch-2.pl
new file mode 100644
index 0000000000..26e3cefb6b
--- /dev/null
+++ b/challenge-046/alicia-bielsa/perl/ch-2.pl
@@ -0,0 +1,32 @@
+#Is the room open?
+#There are 500 rooms in a hotel with 500 employees having keys to all the rooms.
+#The first employee opened main entrance door of all the rooms. The second employee then closed the doors of room numbers 2,4,6,8,10 and so on to 500. The third employee then closed the door if it was opened or opened the door if it was closed of rooms 3,6,9,12,15 and so on to 500. Similarly the fourth employee did the same as the third but only room numbers 4,8,12,16 and so on to 500. This goes on until all employees has had a turn.
+#
+#Write a script to find out all the rooms still open at the end.
+
+use strict;
+use warnings;
+
+my $TOTAL = 500;
+my @aRooms = (0) x $TOTAL;
+foreach my $employee (1..$TOTAL){
+ foreach my $door ($employee..$TOTAL){
+ if ($door % $employee == 0 ){
+ $aRooms[$door-1] = flipStatus ($aRooms[$door-1]);
+ }
+ }
+}
+
+foreach my $room (0..$#aRooms){
+ if ($aRooms[$room]){
+ $room ++;
+ print "Room $room opened\n";
+ }
+}
+sub flipStatus {
+ my $status = shift;
+ if ($status){
+ return 0;
+ }
+ return 1;
+} \ No newline at end of file
diff --git a/challenge-046/andrezgz/perl/ch-1.pl b/challenge-046/andrezgz/perl/ch-1.pl
new file mode 100644
index 0000000000..e2a16bcf71
--- /dev/null
+++ b/challenge-046/andrezgz/perl/ch-1.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-046/
+# Task #1
+# Cryptic Message
+# The communication system of an office is broken and message received
+# are not completely reliable. To send message Hello,
+# it ended up sending these following:
+#
+# H x l 4 !
+# c e - l o
+# z e 6 l g
+# H W l v R
+# q 9 m # o
+# Similary another day we received a message repeatedly like below:
+#
+# P + 2 l ! a t o
+# 1 e 8 0 R $ 4 u
+# 5 - r ] + a > /
+# P x w l b 3 k \
+# 2 e 3 5 R 8 y u
+# < ! r ^ ( ) k 0
+# Write a script to decrypt the above repeated message (one message repeated 6 times).
+#
+# HINT: Look for characters repeated in a particular position in all six messages received.
+
+use strict;
+use warnings;
+
+my $msg = [
+ [qw# P + 2 l ! a t o #],
+ [qw# 1 e 8 0 R $ 4 u #],
+ [qw# 5 - r ] + a > / #],
+ [qw# P x w l b 3 k \ #],
+ [qw# 2 e 3 5 R 8 y u #],
+ [qw# < ! r ^ ( ) k 0 #],
+];
+
+my $msg_len = scalar @{$msg->[0]};
+my @decrypted = ('?') x $msg_len;
+
+for my $i (1 .. @{$msg}-1) {
+ for my $j (0 .. $i-1) {
+ for (0 .. $msg_len-1) {
+ $decrypted[$_] = $msg->[$i]->[$_] if ($msg->[$i]->[$_] eq $msg->[$j]->[$_]);
+ }
+ }
+ print @decrypted,"\n";
+}
+
+__END__
+./ch-1.pl
+????????
+?????a??
+P??l?a??
+Pe?lRa?u
+PerlRaku
diff --git a/challenge-046/andrezgz/perl/ch-2.pl b/challenge-046/andrezgz/perl/ch-2.pl
new file mode 100644
index 0000000000..7a0e0c5565
--- /dev/null
+++ b/challenge-046/andrezgz/perl/ch-2.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-046/
+# Task #2
+# Is the room open?
+# There are 500 rooms in a hotel with 500 employees having keys to all the rooms.
+# The first employee opened main entrance door of all the rooms.
+# The second employee then closed the doors of room numbers 2,4,6,8,10 and so on to 500.
+# The third employee then closed the door if it was opened or opened the door
+# if it was closed of rooms 3,6,9,12,15 and so on to 500.
+# Similarly the fourth employee did the same as the third
+# but only room numbers 4,8,12,16 and so on to 500.
+# This goes on until all employees has had a turn.
+#
+# Write a script to find out all the rooms still open at the end.
+
+use strict;
+use warnings;
+
+use constant MAX => 500;
+
+my @rooms = (-1) x MAX; # all rooms are closed
+unshift @rooms, 0; # add room "0" for simplicity
+
+foreach my $e (1 ..