diff options
author | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
commit | 321825828ac918bad28d0597a8616c6dc9802c3c (patch) | |
tree | 0b8e9cb1012197750eb58e972736319b2a6abac2 /c/rna-transcription/src | |
parent | 2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff) | |
download | exercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz |
Add solved exercises
Diffstat (limited to 'c/rna-transcription/src')
-rw-r--r-- | c/rna-transcription/src/rna_transcription.c | 16 | ||||
-rw-r--r-- | c/rna-transcription/src/rna_transcription.h | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/c/rna-transcription/src/rna_transcription.c b/c/rna-transcription/src/rna_transcription.c new file mode 100644 index 0000000..2328f72 --- /dev/null +++ b/c/rna-transcription/src/rna_transcription.c @@ -0,0 +1,16 @@ +#include "rna_transcription.h" +#include <string.h> +#include <stdlib.h> + +char *to_rna(const char *dna) { + size_t len = strlen(dna); + char *rna = calloc(len + 1, sizeof(*rna)); + for (size_t idx = 0; idx < len; idx++) + switch (dna[idx]) { + case 'G': rna[idx] = 'C'; break; + case 'C': rna[idx] = 'G'; break; + case 'T': rna[idx] = 'A'; break; + case 'A': rna[idx] = 'U'; break; + } + return rna; +} diff --git a/c/rna-transcription/src/rna_transcription.h b/c/rna-transcription/src/rna_transcription.h new file mode 100644 index 0000000..af10db9 --- /dev/null +++ b/c/rna-transcription/src/rna_transcription.h @@ -0,0 +1,6 @@ +#ifndef RNA_TRANSCRIPTION_H +#define RNA_TRANSCRIPTION_H + +char *to_rna(const char *dna); + +#endif |