Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T').
Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and contains no Thymine. In RNA Thymine is replaced by another nucleic acid Uracil ('U').
Create a function which translates a given DNA string into RNA.
For example:
DNAtoRNA("GCAT") returns ("GCAU")
The input string can be of arbitrary length - in particular, it may be empty. All input is guaranteed to be valid, i.e. each input string will only ever consist of 'G', 'C', 'A' and/or 'T'.
Tests
DNAtoRNA("TTTT")
DNAtoRNA("GCAT")
DNAtoRNA("GACCGCCGCC")
Good luck!
This challenge comes from torret 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 (11)
Super simple! I love the polyglot answers 👌🏿
Clojure
Ruby
JavaScript
PHP
I wanted to see what this challenge was about, because I like these combinations of combined fields. So nice to see this come by!
But I am uncomfortable with the fact that this is not the correct way to code transcription (DNA to RNA). RNA is complementary to DNA because it is double-stranded: therefore GCAT should result in CGUA (on a side note: direction is also very important).
I'm curious if there is any particular reason why it is done in the way you described it?
Roost
"Rust"
It works lol
When you don't listen at all
Javascript solution:
Ruby
Ruby
Elm
My Swift solution :
Python solution