aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-01-30 12:02:57 +0000
committerGitHub <noreply@github.com>2020-01-30 12:02:57 +0000
commit3e07c8f5207d766147a83ffbee556e50ab6492bb (patch)
tree257cc3cd35930fc4fd48a6e9daffe88d0a8bf6e6
parent90c9a86c0a6a71c5983433f17606bc009d593e34 (diff)
parent2b8d7a9b09f9a5ac3581a7f982f9ca0a8737ea19 (diff)
downloadperlweeklychallenge-club-3e07c8f5207d766147a83ffbee556e50ab6492bb.tar.gz
perlweeklychallenge-club-3e07c8f5207d766147a83ffbee556e50ab6492bb.tar.bz2
perlweeklychallenge-club-3e07c8f5207d766147a83ffbee556e50ab6492bb.zip
Merge pull request #1182 from choroba/ech045
Add 045 solution (Square Secret Code + Source Dumper) by E. Choroba
-rwxr-xr-xchallenge-045/e-choroba/perl/ch-1.pl17
-rwxr-xr-xchallenge-045/e-choroba/perl/ch-2a.pl8
-rw-r--r--challenge-045/e-choroba/perl/ch-2b.pl1
3 files changed, 26 insertions, 0 deletions
diff --git a/challenge-045/e-choroba/perl/ch-1.pl b/challenge-045/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..9a6b758b09
--- /dev/null
+++ b/challenge-045/e-choroba/perl/ch-1.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+sub square_secret_code {
+ my ($message) = @_;
+ my @code = ("") x 8;
+ for my $group (lc($message) =~ s/\s//gr =~ m/(.{1,8})/g) {
+ $code[$_] .= (split //, $group)[$_] // "" for 0 .. 7;
+ }
+ return join ' ', @code
+}
+
+use Test::More tests => 1;
+is square_secret_code('The quick brown fox jumps over the lazy dog'),
+ 'tbjrd hruto eomhg qwpe unsl ifoa covz kxey',
+ 'encode';
diff --git a/challenge-045/e-choroba/perl/ch-2a.pl b/challenge-045/e-choroba/perl/ch-2a.pl
new file mode 100755
index 0000000000..a98ab5bf84
--- /dev/null
+++ b/challenge-045/e-choroba/perl/ch-2a.pl
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+seek *DATA, 0 , 0;
+print while <DATA>;
+__DATA__
+
diff --git a/challenge-045/e-choroba/perl/ch-2b.pl b/challenge-045/e-choroba/perl/ch-2b.pl
new file mode 100644
index 0000000000..488703eba7
--- /dev/null
+++ b/challenge-045/e-choroba/perl/ch-2b.pl
@@ -0,0 +1 @@
+$_=q!print'$_=q*'.$_.'*;';s/\52/\41/g;print!;print'$_=q!'.$_.'!;';s/\52/\41/g;print \ No newline at end of file