diff options
| author | E. Choroba <choroba@matfyz.cz> | 2019-12-26 00:59:03 +0100 |
|---|---|---|
| committer | E. Choroba <choroba@matfyz.cz> | 2019-12-26 00:59:03 +0100 |
| commit | f98a47cf52857c61beaf1314ec315bd06ef31191 (patch) | |
| tree | 03c3485d50b442a5f851506cdeb1443c74790cf5 | |
| parent | 0cf32143024f741160cb055c9bc4c6c9e16ff9c1 (diff) | |
| download | perlweeklychallenge-club-f98a47cf52857c61beaf1314ec315bd06ef31191.tar.gz perlweeklychallenge-club-f98a47cf52857c61beaf1314ec315bd06ef31191.tar.bz2 perlweeklychallenge-club-f98a47cf52857c61beaf1314ec315bd06ef31191.zip | |
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"; |
