Skip to content
This repository was archived by the owner on Feb 11, 2018. It is now read-only.

Commit

Permalink
Add rna transcription exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
mbertheau committed May 22, 2015
1 parent 89493f7 commit c190ef5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"repository": "https://github.com/exercism/xracket",
"active": false,
"problems": [
"bob"
"bob",
"rna-transcription"
]
}
12 changes: 12 additions & 0 deletions rna-transcription/example.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#lang racket

(define (to-rna sequence)
(list->string
(for/list ([c (in-string sequence)])
(case c
[(#\G) #\C]
[(#\C) #\G]
[(#\T) #\A]
[(#\A) #\U]))))

(provide to-rna)
16 changes: 16 additions & 0 deletions rna-transcription/rna-transcription-test.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#lang racket

(require rackunit
rackunit/text-ui
"rna-transcription.rkt")

(define suite
(test-suite
"Tests for the rna-transcription exercise"
(check-equal? (to-rna "G") "C" "transcribes guanine to cytosine")
(check-equal? (to-rna "C") "G" "transcribes cytosine to guanine")
(check-equal? (to-rna "T") "A" "transcribes thymine to adenine")
(check-equal? (to-rna "A") "U" "transcribes adenine to uracil")
(check-equal? (to-rna "ACGTGGTCTTAA") "UGCACCAGAAUU" "transcribes all occurences")))

(exit (if (zero? (run-tests suite)) 0 1))

0 comments on commit c190ef5

Please sign in to comment.