-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNASTORAGE.cpp
More file actions
47 lines (38 loc) · 914 Bytes
/
DNASTORAGE.cpp
File metadata and controls
47 lines (38 loc) · 914 Bytes
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
/*For encoding an even-length binary string into a sequence of A, T, C, and G, we iterate from left to right and replace the characters as follows:
00 is replaced with A
01 is replaced with T
10 is replaced with C
11 is replaced with G
Given a binary string
�
S of length
�
N (
�
N is even), find the encoded sequence*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
char st[n];
cin>>st;
for(int i = 0;i<n;i=i+2)
{
if(st[i]=='0' && st[i+1]=='0')
cout<<'A';
else if(st[i]=='0' && st[i+1]=='1')
cout<<'T';
else if(st[i]=='1' && st[i+1]=='0')
cout<<'C';
else if(st[i]=='1' && st[i+1]=='1')
cout<<'G';
}
cout<<endl;
}
}