Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 695 Bytes

8 kyu - DNA to RNA Conversion.md

File metadata and controls

27 lines (21 loc) · 695 Bytes

Task

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 funciton which translates a given DNA string into RNA.

For example:

DNAtoRNA("GCAT") returns ("GCAU")

My solution

def DNAtoRNA(dna)
  dna.tr("GCAT", "GCAU")
end

Better / Factored solution

def DNAtoRNA(dna)
  dna.gsub('T', 'U')
end