Sha256: d3f6418360cc0455a598bc747604f17f1bde73dac065f8e4324f1128382537c5
Contents?: true
Size: 1.01 KB
Versions: 25
Compression:
Stored size: 1.01 KB
Contents
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <stdbool.h> #include "nucleotide_count.h" char *count(const char *dna_strand) { bool invalid_char = false; size_t index; size_t nucleotide_a_count = 0; size_t nucleotide_c_count = 0; size_t nucleotide_g_count = 0; size_t nucleotide_t_count = 0; char *count_results = calloc(1, 50); for (index = 0; (index < strlen(dna_strand)) && (invalid_char == false); index++) { switch (dna_strand[index]) { case 'A': nucleotide_a_count++; break; case 'C': nucleotide_c_count++; break; case 'G': nucleotide_g_count++; break; case 'T': nucleotide_t_count++; break; default: invalid_char = true; break; } } if (!invalid_char) { sprintf(count_results, "A:%zd C:%zd G:%zd T:%zd", nucleotide_a_count, nucleotide_c_count, nucleotide_g_count, nucleotide_t_count); } return count_results; }
Version data entries
25 entries across 25 versions & 1 rubygems