diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-12-26 01:48:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-26 01:48:41 +0000 |
| commit | ccdd72ea36bea6e039b988aebb43a96c31577716 (patch) | |
| tree | 6771340e62f0ac1fdeff52f4dc78ecf14c86b8ef | |
| parent | 90550f489d3852c6be8ac7710979d44cb6972610 (diff) | |
| parent | f98a47cf52857c61beaf1314ec315bd06ef31191 (diff) | |
| download | perlweeklychallenge-club-ccdd72ea36bea6e039b988aebb43a96c31577716.tar.gz perlweeklychallenge-club-ccdd72ea36bea6e039b988aebb43a96c31577716.tar.bz2 perlweeklychallenge-club-ccdd72ea36bea6e039b988aebb43a96c31577716.zip | |
Merge pull request #1072 from choroba/ech40
Add solution to 040 by E. Choroba
| -rwxr-xr-x | challenge-040/e-choroba/perl5/ch-1.pl | 15 | ||||
| -rwxr-xr-x | challenge-040/e-choroba/perl5/ch-2.pl | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-040/e-choroba/perl5/ch-1.pl b/challenge-040/e-choroba/perl5/ch-1.pl new file mode 100755 index 0000000000..b24139aa16 --- /dev/null +++ b/challenge-040/e-choroba/perl5/ch-1.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl +use warnings; +use strict; +use feature qw{ say }; +use utf8; + +binmode *STDOUT, ':encoding(UTF-8)'; + +my @arrays = ([qw[ I L O V E Y O U ]], + [qw[ 2 4 0 3 2 0 1 9 ]], + [qw[ ! ? £ $ % ^ & * ]]); + +for my $i (0 .. $#{ $arrays[0] }) { + say join ' ', $i, map $_->[$i], @arrays; +} diff --git a/challenge-040/e-choroba/perl5/ch-2.pl b/challenge-040/e-choroba/perl5/ch-2.pl new file mode 100755 index 0000000000..baaf233c9a --- /dev/null +++ b/challenge-040/e-choroba/perl5/ch-2.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +use warnings; +use strict; + +my @list = (10, 4, 1, 8, 12, 3); +my @indices = (0, 2, 5); + +my @sorted = @list; +@sorted[@indices] = sort { $a <=> $b } @sorted[@indices]; + +my @expected = (1, 4, 3, 8, 12, 10); + +"@sorted" eq "@expected" + or die "Got: @sorted\nExpected: @expected\n"; |
