aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Russell <ac.russell@live.com>2020-12-13 01:37:16 -0500
committerAdam Russell <ac.russell@live.com>2020-12-13 01:37:16 -0500
commit76d2fecd7ff88a846d1a3fedc2b6efb4d6345a72 (patch)
treec1cc7d8d5ae5468262bc6002c7615552f3f81111
parent8a42c26f2b60130c648d864f7963444663267110 (diff)
downloadperlweeklychallenge-club-76d2fecd7ff88a846d1a3fedc2b6efb4d6345a72.tar.gz
perlweeklychallenge-club-76d2fecd7ff88a846d1a3fedc2b6efb4d6345a72.tar.bz2
perlweeklychallenge-club-76d2fecd7ff88a846d1a3fedc2b6efb4d6345a72.zip
initial commit
-rw-r--r--challenge-090/adam-russell/blog.txt0
-rw-r--r--challenge-090/adam-russell/perl/ch-1.pl27
-rw-r--r--challenge-090/adam-russell/perl/ch-2.pl23
3 files changed, 50 insertions, 0 deletions
diff --git a/challenge-090/adam-russell/blog.txt b/challenge-090/adam-russell/blog.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/challenge-090/adam-russell/blog.txt
diff --git a/challenge-090/adam-russell/perl/ch-1.pl b/challenge-090/adam-russell/perl/ch-1.pl
new file mode 100644
index 0000000000..382f19295f
--- /dev/null
+++ b/challenge-090/adam-russell/perl/ch-1.pl
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+##
+# Write a script to print the nucleiobase count in
+# the given DNA sequence. Also print the complementary
+# sequence where Thymine (T) on one strand is always
+# facing an adenine (A) and vice versa; guanine (G) is
+# always facing a cytosine (C) and vice versa.
+##
+use constant SEQUENCE => "GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG";
+my %nucleotide_map = (
+ "T" => "A",
+ "A" => "T",
+ "G" => "C",
+ "C" => "G"
+);
+
+sub complementary_sequence{
+ my($sequence) = @_;
+ my @complement = map { $nucleotide_map{$_} } split(//, $sequence);
+ return @complement;
+}
+
+MAIN:{
+ print "length of sequence: " . length(SEQUENCE) . "\n";
+ print "complementary sequence: " . join("", complementary_sequence(SEQUENCE)) . "\n";
+}
diff --git a/challenge-090/adam-russell/perl/ch-2.pl b/challenge-090/adam-russell/perl/ch-2.pl
new file mode 100644
index 0000000000..6d5d0a4852
--- /dev/null
+++ b/challenge-090/adam-russell/perl/ch-2.pl
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+##
+# You are given two positive numbers $A and $B.
+# Write a script to demonstrate Ethiopian Multiplication
+# using the given numbers.
+##
+sub ethiopian_multiplication{
+ my($a, $b) = @_;
+ my @steps;
+ my ($x, $y) = ($a, $b);
+ do{
+ $x = int($x / 2);
+ $y = $y * 2;
+print "$x $y\n";
+ push @steps, [$x, $y];
+ }until $steps[-1]->[0] == 1 || $steps[-1]->[1] == 1;
+}
+
+MAIN:{
+ my($A, $B) = (14, 12);
+ ethiopian_multiplication($A, $B);
+}