From c190ef5d5d9cc33e2085622910f8e1131e1d6000 Mon Sep 17 00:00:00 2001 From: Markus Bertheau Date: Fri, 22 May 2015 23:22:05 +0200 Subject: [PATCH] Add rna transcription exercise --- config.json | 3 ++- rna-transcription/example.rkt | 12 ++++++++++++ rna-transcription/rna-transcription-test.rkt | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 rna-transcription/example.rkt create mode 100644 rna-transcription/rna-transcription-test.rkt diff --git a/config.json b/config.json index 6dc26b3..f2a0ed4 100644 --- a/config.json +++ b/config.json @@ -4,6 +4,7 @@ "repository": "https://github.com/exercism/xracket", "active": false, "problems": [ - "bob" + "bob", + "rna-transcription" ] } diff --git a/rna-transcription/example.rkt b/rna-transcription/example.rkt new file mode 100644 index 0000000..133271e --- /dev/null +++ b/rna-transcription/example.rkt @@ -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) diff --git a/rna-transcription/rna-transcription-test.rkt b/rna-transcription/rna-transcription-test.rkt new file mode 100644 index 0000000..12f886a --- /dev/null +++ b/rna-transcription/rna-transcription-test.rkt @@ -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))