Advertisement
Guest User

Untitled

a guest
Aug 16th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. // In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". You have function with one side of the DNA (string, except for Haskell); you need to get the other complementary side. DNA strand is never empty or there is no DNA at all (again, except for Haskell).
  2.  
  3. // Example: (input: output)
  4.  
  5. // dna_strand("ATTGC") /* return "TAACG" */
  6. // dna_strand("GTAT")  /* return "CATA"  */
  7.  
  8. #include <stdlib.h>
  9. #include <string.h>
  10.  
  11. char *dna_strand(const char *dna)
  12. {
  13.     char     *out;
  14.     unsigned  idx;
  15.  
  16.     out = calloc(1, strlen(dna) + 1);
  17.     for(idx = 0; dna[idx]; ++idx)
  18.         out[idx] = (2652 / (11 * dna[idx] - 703) + 703) / 11;
  19.  
  20.     return out;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement