-
Notifications
You must be signed in to change notification settings - Fork 0
/
dna.ts
72 lines (58 loc) · 1.58 KB
/
dna.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Instructions
/*
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"
*/
// /* Prep */
// Parameters:
// Returns:
function foo(bar) {
// Pseudo:
return;
}
export class Kata {
static dnaStrand(dna: string): string {
//your code here
return dna
.split("")
.map((el) => {
switch (el) {
case "A":
return "T";
break;
case "C":
return "G";
break;
case "T":
return "A";
break;
case "G":
return "C";
break;
default:
break;
}
})
.join("");
}
}
// Examples:
console.log(Kata.dnaStrand("ATTGC")); // =>
// Favorite solution
// export class Kata {
// static dnaStrand(dna: string): string{
// //your code here
// const match = {
// 'A': 'T',
// 'T': 'A',
// 'G': 'C',
// 'C': 'G'
// }
// return Array.from(dna, v=>match[v]).join('');
// }
// }