[Coding Challenge] Complementary DNA
Hello community,
Yesterday was celebrated the "World Medical Ethics Day" https://www.ama.com.au/media/wma-medical-ethics-day
We could celebrate it with a programming quiz or challenge:
DESCRIPTION:
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.If you want to know more: http://en.wikipedia.org/wiki/DNA
In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". Your function receives one side of the DNA (string, except for Haskell); you need to return the other complementary side. DNA strand is never empty or there is no DNA at all (again, except for Haskell).
More similar exercise are found here: http://rosalind.info/problems/list-view/ (source)
Example: (input --> output)
"ATTGC" --> "TAACG" "GTAT" --> "CATA"
Satement extracted from: https://www.codewars.com/kata/554e4a2f232cdd87d9000038/java
Test cases:
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class DnaStrandTest { @Test public void test01() { assertEquals("TTTT", DnaStrand.makeComplement("AAAA")); } @Test public void test02() { assertEquals("TAACG", DnaStrand.makeComplement("ATTGC")); } @Test public void test03() { assertEquals("CATA", DnaStrand.makeComplement("GTAT")); } @Test public void test04() { assertEquals("TTCC", DnaStrand.makeComplement("AAGG")); } @Test public void test05() { assertEquals("GCGC", DnaStrand.makeComplement("CGCG")); } @Test public void test06() { assertEquals("TAACG", DnaStrand.makeComplement("ATTGC")); } @Test public void test07() { assertEquals("CATAGCTAGCTAGCTAGCTAATATAAAAGCTGCTCTAAATTTATATATATATATGCTCTCTTATGTCTATCTGTCTAAT", DnaStrand.makeComplement("GTATCGATCGATCGATCGATTATATTTTCGACGAGATTTAAATATATATATATACGAGAGAATACAGATAGACAGATTA")); } }
🌐🕸📔 Would you be able to code a solution for this?