diff options
| author | 冯昶 <seaker@qq.com> | 2021-03-15 18:18:09 +0800 |
|---|---|---|
| committer | 冯昶 <seaker@qq.com> | 2021-03-15 18:18:09 +0800 |
| commit | 5ed25077fde85262036c9db3e893d70ae0907b5c (patch) | |
| tree | 8932d25b3fa6076e2d91ab2a331d4d8bfff20544 /challenge-090/paulo-custodio/lua | |
| parent | 8b6be37fe4dac8b4c6489a95e55514b76b298d15 (diff) | |
| parent | 65d54d52500028ec5359a7d39619803ade281543 (diff) | |
| download | perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.tar.gz perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.tar.bz2 perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-090/paulo-custodio/lua')
| -rw-r--r-- | challenge-090/paulo-custodio/lua/ch-1.lua | 32 | ||||
| -rw-r--r-- | challenge-090/paulo-custodio/lua/ch-2.lua | 28 |
2 files changed, 60 insertions, 0 deletions
diff --git a/challenge-090/paulo-custodio/lua/ch-1.lua b/challenge-090/paulo-custodio/lua/ch-1.lua new file mode 100644 index 0000000000..8126c4a171 --- /dev/null +++ b/challenge-090/paulo-custodio/lua/ch-1.lua @@ -0,0 +1,32 @@ +#!/usr/bin/env lua + +--[[ +Challenge 090 + +TASK #1 > DNA Sequence +Submitted by: Mohammad S Anwar +DNA is a long, chainlike molecule which has two strands twisted into a +double helix. The two strands are made up of simpler molecules called +nucleotides. Each nucleotide is composed of one of the four nitrogen-containing +nucleobases cytosine (C), guanine (G), adenine (A) and thymine (T). + +You are given DNA sequence, +GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG. + +Write a script to print 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. +--]] + +function complement(seq) + local trans = {T = "A", A = "T", G = "C", C = "G"} + local compl = string.gsub(seq, "[TAGC]", trans) + return compl +end + +seq = arg[1] +compl = complement(seq) + +io.write(#seq, "\n") +io.write(compl) diff --git a/challenge-090/paulo-custodio/lua/ch-2.lua b/challenge-090/paulo-custodio/lua/ch-2.lua new file mode 100644 index 0000000000..d9e54b052f --- /dev/null +++ b/challenge-090/paulo-custodio/lua/ch-2.lua @@ -0,0 +1,28 @@ +#!/usr/bin/env lua + +--[[ +Challenge 090 + +TASK #2 > Ethiopian Multiplication +Submitted by: Mohammad S Anwar +You are given two positive numbers $a and $b. + +Write a script to demonstrate Ethiopian Multiplication using the given numbers. +--]] + +function mul(a, b) + local m = 0 + while (true) do + if ((a & 1) ~= 0) then + m = m + b + end + if (a <= 1) then + break + end + a = a >> 1 + b = b << 1 + end + return m +end + +io.write(mul(tonumber(arg[1]), tonumber(arg[2])), "\n") |
