# Complementary DNA

## [Complementary DNA](https://www.codewars.com/kata/554e4a2f232cdd87d9000038)

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". You have a 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).

More similar exercise are found here <http://rosalind.info/problems/list-view/> (source)

```python
DNA_strand ("ATTGC") # return "TAACG"

DNA_strand ("GTAT") # return "CATA"
```

```javascript
DNAStrand ("ATTGC") // return "TAACG"

DNAStrand ("GTAT") // return "CATA"
```

```typescript
dnaStrand("ATTGC") // return "TAACG"

dnaStrand("GTAT") // return "CATA"
```

```csharp
MakeComplement("ATTGC") => "TAACG"

MakeComplement("GTAT") => "CATA"
```

```php
DNA_strand("ATTGC") // returns "TAACG"
DNA_strand("GTAT") // returns "CATA"
```

```ruby
DNA_strand ("ATTGC") # return "TAACG"

DNA_strand ("GTAT") # return "CATA"
```

```
dna_strand("ATTGC") # return "TAACG"

dna_strand("GTAT") # return "CATA"
```

```java
DnaStrand.makeComplement("ATTGC") // return "TAACG"

DnaStrand.makeComplement("GTAT") // return "CATA"
```

```kotlin
makeComplement("ATTGC") // return "TAACG"

makeComplement("GTAT") // return "CATA"
```

```haskell
dnaStrand []        `shouldBe` []
dnaStrand [A,T,G,C] `shouldBe` [T,A,C,G]
dnaStrand [G,T,A,T] `shouldBe` [C,A,T,A]
dnaStrand [A,A,A,A] `shouldBe` [T,T,T,T]
```

```
(is (= (dna-strand "ATTGC") "TAACG"))

(is (= (dna-strand "GTAT") "CATA"))
```

```c
dna_strand("ATTGC") /* return "TAACG" */
dna_strand("GTAT")  /* return "CATA"  */
```

```go
DNAStrand("ATTGC") // returns "TAACG"

DNAStrand("GTAT") // returns "CATA"
```

```rust
dna_strand("ATTGC") // returns "TAACG"
dna_strand("GTAT")  // returns "CATA"
```

```julia
dnastrand("ATTGC") # returns "TAACG"
dnastrand("GTAT")  # returns "CATA"
```

```
dna_strand("ATTGC") == "TAACG"
dna_strand("GTAT") == "CATA"
```

## Solutions

### 🐍 Python

```python
def DNA_strand(dna):
    return "".join(['T' if v == 'A' else 'A' if v == 'T' else 'G' if v == 'C' else 'C' for v in dna])
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://anton-veselskyi.gitbook.io/codding-problems-solutions/codewars/7-kyu/complementary-dna.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
