diff options
| author | juliodcs <julio.dcs@gmail.com> | 2020-12-12 01:12:48 +0100 |
|---|---|---|
| committer | juliodcs <julio.dcs@gmail.com> | 2020-12-12 01:12:48 +0100 |
| commit | 707e308ed8be245e461f9f5132187cae8b4cd16e (patch) | |
| tree | 1d5454bbd5048f222c5a53c47ac8e989588f2698 /challenge-090/juliodcs/perl | |
| parent | 931e28a9fe63ad0942cf9f3099191a0e21a978c2 (diff) | |
| download | perlweeklychallenge-club-707e308ed8be245e461f9f5132187cae8b4cd16e.tar.gz perlweeklychallenge-club-707e308ed8be245e461f9f5132187cae8b4cd16e.tar.bz2 perlweeklychallenge-club-707e308ed8be245e461f9f5132187cae8b4cd16e.zip | |
juliodcs-week90
Diffstat (limited to 'challenge-090/juliodcs/perl')
| -rw-r--r-- | challenge-090/juliodcs/perl/ch-1.pl | 9 | ||||
| -rw-r--r-- | challenge-090/juliodcs/perl/ch-2.pl | 34 |
2 files changed, 43 insertions, 0 deletions
diff --git a/challenge-090/juliodcs/perl/ch-1.pl b/challenge-090/juliodcs/perl/ch-1.pl new file mode 100644 index 0000000000..e988d6bf0f --- /dev/null +++ b/challenge-090/juliodcs/perl/ch-1.pl @@ -0,0 +1,9 @@ +use strict;
+use warnings;
+use feature 'say';
+
+my $input = shift // 'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG';
+
+say "Input : $input";
+say 'Length : ' . $input =~ tr/TAGC/ATCG/;
+say "Complementary : $input";
diff --git a/challenge-090/juliodcs/perl/ch-2.pl b/challenge-090/juliodcs/perl/ch-2.pl new file mode 100644 index 0000000000..a5c42b4d08 --- /dev/null +++ b/challenge-090/juliodcs/perl/ch-2.pl @@ -0,0 +1,34 @@ +use strict;
+use warnings;
+use feature 'say';
+use experimental 'signatures';
+use List::Util 'sum0';
+
+my ($first, $second) = @ARGV;
+
+die 'Please input 2 numbers' if not @ARGV == 2;
+
+say "Ethiopian multiplication of $first and $second\n";
+
+sub operate(@items) {
+ my $last = @items[@items - 1];
+
+ $last->[0] == 1
+ ? @items
+ : operate (@items, [int($last->[0] / 2), $last->[1] * 2])
+}
+
+my @steps = operate([$first, $second]);
+say 'Steps:';
+say join ', ', $_->@* for @steps;
+
+say "\nKepp odd numbers:";
+my @odd = grep { $_->[0] % 2 } @steps;
+say join ', ', $_->@* for @odd;
+
+say "\nKeep right values:";
+my @right = map { $_->[1] } @odd;
+say $_ for @right;
+
+say "\nAdd the numbers:";
+say sum0 @right;
|
