aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-12-08 10:10:32 +0000
committerGitHub <noreply@github.com>2020-12-08 10:10:32 +0000
commitabc10c5ec165070f060b05767c5ef5a2b7ec5196 (patch)
tree6693cca9adfc6d784bc22250d6829451590f02f1
parent30d0a036bc35f1376adb3181f0477643775fb5ec (diff)
parent52e0077613ff011285f9e381f774bb9ce56be99a (diff)
downloadperlweeklychallenge-club-abc10c5ec165070f060b05767c5ef5a2b7ec5196.tar.gz
perlweeklychallenge-club-abc10c5ec165070f060b05767c5ef5a2b7ec5196.tar.bz2
perlweeklychallenge-club-abc10c5ec165070f060b05767c5ef5a2b7ec5196.zip
Merge pull request #2947 from jacoby/master
Ch90
-rw-r--r--challenge-090/dave-jacoby/blog.txt1
-rw-r--r--challenge-090/dave-jacoby/perl/ch-1.pl22
-rw-r--r--challenge-090/dave-jacoby/perl/ch-2.pl38
3 files changed, 61 insertions, 0 deletions
diff --git a/challenge-090/dave-jacoby/blog.txt b/challenge-090/dave-jacoby/blog.txt
new file mode 100644
index 0000000000..b692db20a0
--- /dev/null
+++ b/challenge-090/dave-jacoby/blog.txt
@@ -0,0 +1 @@
+https://jacoby.github.io/2020/12/08/multiplication-and-dna-perl-weekly-challenge-90.html \ No newline at end of file
diff --git a/challenge-090/dave-jacoby/perl/ch-1.pl b/challenge-090/dave-jacoby/perl/ch-1.pl
new file mode 100644
index 0000000000..ed5f5e8cc6
--- /dev/null
+++ b/challenge-090/dave-jacoby/perl/ch-1.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use feature qw{ say signatures state };
+no warnings qw{ experimental };
+
+my $sequence = 'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG' ;
+my $complement = $sequence;
+$complement =~ tr/TACG/ATGC/;
+
+say <<"END";
+ Sequence: $sequence
+ Complement: $complement
+END
+
+for my $i ( qw( A T C G ) ) {
+ my $n = scalar grep {/$i/} split // , $sequence;
+ say qq( $i: $n );
+}
+
+
diff --git a/challenge-090/dave-jacoby/perl/ch-2.pl b/challenge-090/dave-jacoby/perl/ch-2.pl
new file mode 100644
index 0000000000..2973f52f1d
--- /dev/null
+++ b/challenge-090/dave-jacoby/perl/ch-2.pl
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use feature qw{ say signatures state };
+no warnings qw{ experimental };
+
+use Scalar::Util qw{looks_like_number};
+
+my ( $m, $n ) = map { abs $_ } grep { looks_like_number $_ } @ARGV;
+
+$m //= 17;
+$n //= 38;
+
+say <<"END";
+
+ m $m
+ n $n
+END
+
+say egyptian( $m, $n );
+say $m * $n;
+
+exit;
+
+sub egyptian ( $m, $n ) {
+ my $o = 0;
+ my $i = 1;
+ do {
+ my $e = $m % 2 != 0 ? 1 : 0;
+ say join "\t", $o, $e, $i, $m, $n;
+ $o += $n if $e;
+ $i *= 2;
+ $m = int $m / 2;
+ $n = $n * 2;
+ } while ( $m > 0 );
+ return $o;
+}