Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rna-transcription issue #104

Merged
merged 1 commit into from Aug 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/rna_transcription.yml
@@ -0,0 +1,15 @@
---
level: easy
tags: [strings]
description: |
Write a program that, given a DNA strand, returns 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 thymidine (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
multicode_checks:
langs: [ruby, javascript, python, php]
18 changes: 18 additions & 0 deletions test/battle_solutions/rna_transcription_test.clj
@@ -0,0 +1,18 @@
(ns battle-solutions.rna-transcription-test
(:require [clojure.test :refer :all]
[battle-asserts.test-helper :refer [assert-equal]]))

(defn to-rna
[dna]
(let [transcription {\C \G
\G \C
\A \U
\T \A}]
(apply str
(map #(transcription %) dna))))

(deftest test-asserts
(assert-equal "G" (to-rna "C"))
(assert-equal "C" (to-rna "G"))
(assert-equal "U" (to-rna "A"))
(assert-equal "UGCACCAGAAUU" (to-rna "ACGTGGTCTTAA")))