🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io 🎉
Avatar of JaeHyoLee

JaeHyoLee's solution

to RNA Transcription in the Lua Track

Published at Jul 13 2018 · 6 comments
Test suite

Given a DNA strand, return its RNA complement (per RNA transcription).

Both DNA and RNA strands are a sequence of nucleotides.

The four nucleotides found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T).

The four nucleotides found in RNA are adenine (A), cytosine (C), guanine (G) and uracil (U).

Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement:

  • G -> C
  • C -> G
  • T -> A
  • A -> U

Running the tests

To run the tests, run the command busted from within the exercise directory.

Further information

For more detailed information about the Lua track, including how to get help if you're having trouble, please visit the exercism.io Lua language page.


Hyperphysics http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


local to_rna = require('rna-transcription')

describe('rna-transcription', function()
  it('transcribes cytosine to guanosine', function()
    assert.are.equal('G', to_rna('C'))

  it('transcribes guanosine to cytosine', function()
    assert.are.equal('C', to_rna('G'))

  it('transcribes adenosine to uracil', function()
    assert.are.equal('U', to_rna('A'))

  it('transcribes thymine to adenosine', function()
    assert.are.equal('A', to_rna('T'))

  it('transcribes all DNA nucleotides to their RNA complements', function()
    assert.are.equal('UGCACCAGAAUU', to_rna('ACGTGGTCTTAA'))
return function(dna)
  return (dna:gsub('[CGAT]', { C = 'G', G = 'C', A = 'U', T = 'A' }))

Community comments

Find this solution interesting? Ask the author a question to learn more.
Avatar of StevenRoot

looks good to me... although I think iteration 1 is actual crystal clear for new ruby folks too

Avatar of StevenRoot

lol -- working multiple tracks... "lua" but thanks for the trivial it is always helpful

Avatar of JaeHyoLee

haha. I may need to start work on Ruby now :) What other languages most of you guys are working on in exercism? except for lua

Avatar of ryanplusplus

Mostly Lua and Clojure for me. I did a little bit of Ruby, but not too much. I am planning to do Haskell soon.

What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?