diff options
| author | E. Choroba <choroba@matfyz.cz> | 2020-01-29 23:48:28 +0100 |
|---|---|---|
| committer | E. Choroba <choroba@matfyz.cz> | 2020-01-29 23:51:20 +0100 |
| commit | 2b8d7a9b09f9a5ac3581a7f982f9ca0a8737ea19 (patch) | |
| tree | 19426af7706a63a51b3763e26049d743737f3a11 /challenge-045/e-choroba | |
| parent | bf0d241076c0e080fd5df2f7a02a499a6d9da6d0 (diff) | |
| download | perlweeklychallenge-club-2b8d7a9b09f9a5ac3581a7f982f9ca0a8737ea19.tar.gz perlweeklychallenge-club-2b8d7a9b09f9a5ac3581a7f982f9ca0a8737ea19.tar.bz2 perlweeklychallenge-club-2b8d7a9b09f9a5ac3581a7f982f9ca0a8737ea19.zip | |
Add 045 solution (Square Secret Code + Source Dumper) by E. Choroba
Quine added as an alternative solution
Diffstat (limited to 'challenge-045/e-choroba')
| -rwxr-xr-x | challenge-045/e-choroba/perl/ch-1.pl | 17 | ||||
| -rwxr-xr-x | challenge-045/e-choroba/perl/ch-2a.pl | 8 | ||||
| -rw-r--r-- | challenge-045/e-choroba/perl/ch-2b.pl | 1 |
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 |
