diff options
| author | k-mx <cppfero@gmail.com> | 2020-02-02 17:14:08 +0500 |
|---|---|---|
| committer | k-mx <cppfero@gmail.com> | 2020-02-03 00:04:35 +0500 |
| commit | c2c50f5f694fc2b347581ea2f75216aa2e969f1c (patch) | |
| tree | 4b1c0866cffbf8e6544fbc6f950415aaa3d7f9c8 | |
| parent | 50f57a2e61b5f8a67894cb5fb1963c2c419ace76 (diff) | |
| download | perlweeklychallenge-club-c2c50f5f694fc2b347581ea2f75216aa2e969f1c.tar.gz perlweeklychallenge-club-c2c50f5f694fc2b347581ea2f75216aa2e969f1c.tar.bz2 perlweeklychallenge-club-c2c50f5f694fc2b347581ea2f75216aa2e969f1c.zip | |
challenge-045, pt. 1 and 2
| -rw-r--r-- | challenge-045/maxim-kolodyazhny/perl/ch-1.pl | 16 | ||||
| -rw-r--r-- | challenge-045/maxim-kolodyazhny/perl/ch-2.pl | 6 | ||||
| -rw-r--r-- | challenge-045/maxim-kolodyazhny/perl/t/ch-1.t | 25 |
3 files changed, 47 insertions, 0 deletions
diff --git a/challenge-045/maxim-kolodyazhny/perl/ch-1.pl b/challenge-045/maxim-kolodyazhny/perl/ch-1.pl new file mode 100644 index 0000000000..b127acb87d --- /dev/null +++ b/challenge-045/maxim-kolodyazhny/perl/ch-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +$_ = lc <>; +s/\s//g; + +for my $i ( 0..7 ) { + + last if ( pos = $i ) == length; + + print + $i ? ' ' : '', + /(.).{0,7}/g; +} diff --git a/challenge-045/maxim-kolodyazhny/perl/ch-2.pl b/challenge-045/maxim-kolodyazhny/perl/ch-2.pl new file mode 100644 index 0000000000..722e465848 --- /dev/null +++ b/challenge-045/maxim-kolodyazhny/perl/ch-2.pl @@ -0,0 +1,6 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +open 0 and print <0>; diff --git a/challenge-045/maxim-kolodyazhny/perl/t/ch-1.t b/challenge-045/maxim-kolodyazhny/perl/t/ch-1.t new file mode 100644 index 0000000000..9565bde2fe --- /dev/null +++ b/challenge-045/maxim-kolodyazhny/perl/t/ch-1.t @@ -0,0 +1,25 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use FindBin qw($Bin); + +use Test::More tests => 8; + +my %s = ( + '1 2' => '1 2', + '1' => '1', + '123' => '1 2 3', + '12345678' => '1 2 3 4 5 6 7 8', + '123456789' => '19 2 3 4 5 6 7 8', + '1234567890' => '19 20 3 4 5 6 7 8', + 'The quick brown fox jumps over the lazy dog' => 'tbjrd hruto eomhg qwpe unsl ifoa covz kxey', + 'https://github.com/manwar/perlweeklychallenge-club' => 'hgorelu tim/keb tt/pln phmeyg suarce :bnlh- /.wwac /caell', +); + +while ( my ( $s, $r ) = each %s ) { + + my $r2 = `echo '$s' | perl $Bin/../ch-1.pl`; + + is( $r2, $r ); +} |
