From 321825828ac918bad28d0597a8616c6dc9802c3c Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 11 Aug 2021 15:26:15 +0530 Subject: Add solved exercises --- c/rna-transcription/src/rna_transcription.c | 16 ++++++++++++++++ c/rna-transcription/src/rna_transcription.h | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 c/rna-transcription/src/rna_transcription.c create mode 100644 c/rna-transcription/src/rna_transcription.h (limited to 'c/rna-transcription/src') 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 +#include + +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 -- cgit 1.4.1-2-gfad0