mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-12-22 14:43:10 -05:00
31 lines
486 B
C
31 lines
486 B
C
#include "rna_transcription.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
char *to_rna(const char *dna) {
|
|
|
|
size_t len = strlen(dna);
|
|
char *rna = calloc(len + 1, sizeof(char));
|
|
|
|
for (size_t i = 0; i < len; ++i) {
|
|
switch (dna[i]) {
|
|
case 'G':
|
|
rna[i] = 'C';
|
|
break;
|
|
case 'C':
|
|
rna[i] = 'G';
|
|
break;
|
|
case 'T':
|
|
rna[i] = 'A';
|
|
break;
|
|
case 'A':
|
|
rna[i] = 'U';
|
|
break;
|
|
default:
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
return rna;
|
|
}
|