From ee68f2279fe0a02608d6f7d8e089c8b57d4fadb4 Mon Sep 17 00:00:00 2001 From: Christian Bender Date: Fri, 26 Jan 2018 19:32:30 +0100 Subject: [PATCH] Add files via upload --- .../rna-transcription/rna_transcription.c | 38 +++++++++++++++++++ .../rna-transcription/rna_transcription.h | 7 ++++ 2 files changed, 45 insertions(+) create mode 100644 exercism/rna-transcription/rna_transcription.c create mode 100644 exercism/rna-transcription/rna_transcription.h diff --git a/exercism/rna-transcription/rna_transcription.c b/exercism/rna-transcription/rna_transcription.c new file mode 100644 index 00000000..856af351 --- /dev/null +++ b/exercism/rna-transcription/rna_transcription.c @@ -0,0 +1,38 @@ +#include +#include +#include + +char *to_rna(const char s[]) +{ + + /* determines the length of the given string */ + int len = strlen(s); + + /* creates a return string */ + char *ans = malloc(sizeof(char) * len); + + /* for the loop */ + int i = 0; + + /* actual compile process */ + for (i = 0; i < len; i++) + { + switch (s[i]) + { + case 'G': + ans[i] = 'C'; + break; + case 'C': + ans[i] = 'G'; + break; + case 'T': + ans[i] = 'A'; + break; + case 'A': + ans[i] = 'U'; + break; + } + } + + return ans; +} \ No newline at end of file diff --git a/exercism/rna-transcription/rna_transcription.h b/exercism/rna-transcription/rna_transcription.h new file mode 100644 index 00000000..6c3bc0f1 --- /dev/null +++ b/exercism/rna-transcription/rna_transcription.h @@ -0,0 +1,7 @@ +#ifndef __RNA_TRANSCRIPTION__H +#define __RNA_TRANSCRIPTION__H + +/* to_rna: compiles a DNA strand in its RNA complement */ +char * to_rna(const char s[]); + +#endif \ No newline at end of file