diff options
| -rw-r--r-- | challenge-090/nunovieira220/js/ch-1.js | 20 | ||||
| -rw-r--r-- | challenge-090/nunovieira220/js/ch-2.js | 15 | ||||
| -rw-r--r-- | challenge-090/nunovieira220/perl/ch-1.pl | 26 | ||||
| -rw-r--r-- | challenge-090/nunovieira220/perl/ch-2.pl | 22 |
4 files changed, 83 insertions, 0 deletions
diff --git a/challenge-090/nunovieira220/js/ch-1.js b/challenge-090/nunovieira220/js/ch-1.js new file mode 100644 index 0000000000..16e2b55cdc --- /dev/null +++ b/challenge-090/nunovieira220/js/ch-1.js @@ -0,0 +1,20 @@ +// Input +const sequence = "GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG"; + +// DNA Sequence +const convert = {'T': 'A', 'A': 'T', 'G': 'C', 'C': 'G'}; +const counters = {'A': 0, 'C': 0, 'G': 0, 'T': 0}; +let complementary = ''; + +sequence.split('').forEach(base => { + counters[base]++; + complementary += convert[base]; +}); + +// Output +const { A, C, G, T } = counters; +console.log(`Adenine: ${A}`); +console.log(`Cytosine: ${C}`); +console.log(`Guanine: ${G}`); +console.log(`Thymine: ${T}`); +console.log(`Complementary: ${complementary}`);
\ No newline at end of file diff --git a/challenge-090/nunovieira220/js/ch-2.js b/challenge-090/nunovieira220/js/ch-2.js new file mode 100644 index 0000000000..f37bef53cb --- /dev/null +++ b/challenge-090/nunovieira220/js/ch-2.js @@ -0,0 +1,15 @@ +// Input +let A = 14; +let B = 12; + +// Ethiopian Multiplication +let res = 0; + +while(A > 1) { + A = Math.floor(A / 2); + B = B * 2; + res += B; +} + +// Output +console.log(res);
\ No newline at end of file diff --git a/challenge-090/nunovieira220/perl/ch-1.pl b/challenge-090/nunovieira220/perl/ch-1.pl new file mode 100644 index 0000000000..0f61d11db5 --- /dev/null +++ b/challenge-090/nunovieira220/perl/ch-1.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use feature qw(say); +use Data::Dumper; + +# Input +my $sequence = "GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG"; + +# DNA Sequence +my %convert = ('T', 'A', 'A', 'T', 'G', 'C', 'C', 'G'); +my %counters = ('A', 0, 'C', 0, 'G', 0, 'T', 0); +my $complementary = ''; + +for (split('', $sequence)) { + $counters{$_}++; + $complementary .= $convert{$_}; +} + +# Output +say "Adenine: ".$counters{'A'}; +say "Cytosine: ".$counters{'C'}; +say "Guanine: ".$counters{'G'}; +say "Thymine: ".$counters{'T'}; +say "Complementary: ".$complementary;
\ No newline at end of file diff --git a/challenge-090/nunovieira220/perl/ch-2.pl b/challenge-090/nunovieira220/perl/ch-2.pl new file mode 100644 index 0000000000..ea272fe60c --- /dev/null +++ b/challenge-090/nunovieira220/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use feature qw(say); +use POSIX; + +# Input +my $A = 14; +my $B = 12; + +# Ethiopian Multiplication +my $res = 0; + +while($A > 1) { + $A = floor($A / 2); + $B = $B * 2; + $res += $B; +} + +# Output +say $res;
\ No newline at end of file |
