Setup
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.
In DNA strings, symbols "A" and "T"
and "C" and "G"
are complements of each other. Implement a function DNA_strand
to match the given side of DNA with its complementary side.
Examples
DNA_strand("ATTGC")
# return TAACG
DNA_strand("GTTAAC")
# return CAATTG
Tests
DNA_strand("AAAA")
DNA_strand("CTACC")
DNA_strand("GTAT")
Good luck!
This challenge comes from JustyFY on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (18)
This sounds like a one-liner in JS. Let's see...
As a bonus, any non-DNA letters will be ignored.
i am fresher can you tell me what does this ( => )operator do.
Your help is appreciated.
It’s an arrow function (or anonymous function).
function(a, b) {return a + b;}
Is (almost) the same as:
(a, b) => a + b
There are a few differences but most of the time they aren’t anything to worry about. If you care, this is a good overview: levelup.gitconnected.com/7-differe...
JS:
Ruby keeps on pleasantly surprising me:
Seems like Lua also has a neat solution:
Another javascript solution
JavaScript:
In Python:
C#
---- -|--
- this bit always changes---| ---|
- this bits only changes when---- --|-
is set to 0Haskell:
Returns a Left value if there is a character other than AGTC
Swift solution :
Swift:
I'm trying to complete these everyday for 30 days (hopefully more) - feedback more that welcome here please, thank you! Github PR