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.
DNA_strand("ATTGC") # return
DNA_strand("GTTAAC") # return
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 firstname.lastname@example.org with your suggestions!
Top comments (16)
Ruby keeps on pleasantly surprising me:
Seems like Lua also has a neat solution:
This sounds like a one-liner in JS. Let's see...
As a bonus, any non-DNA letters will be ignored.
Returns a Left value if there is a character other than AGTC
Swift solution :
I'm trying to complete these everyday for 30 days (hopefully more) - feedback more that welcome here please, thank you! Github PR
There is always a better solution, suggest one please - I'm here to learn more .)
OK, I found another one for PHP (7.2 and higher):
---- -|--- this bit always changes
---| ---|- this bits only changes when
---- --|-is set to 0