-
Notifications
You must be signed in to change notification settings - Fork 2
/
ATGC_Encoder.c
90 lines (76 loc) · 982 Bytes
/
ATGC_Encoder.c
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <string.h>
int main(){
int t;
scanf("%d",&t);
char alice[t];
char bob[t];
scanf("%s", alice);
/*
A = 65
T = 84
G = 71
C = 67
0 = 48
1 = 49
2 = 50
3 = 51
*/
bob[0] = 65;
for(int i = 1; i<t; i++){
if(alice[i] != 51){
if(bob[i-1] == 65){
//A
if(alice[i] == 48){
bob[i] = 67;
}
else if(alice[i] == 49){
bob[i] = 71;
}
else{
bob[i] = 84;
}
}
else if(bob[i-1] == 84){
//T
if(alice[i] == 48){
bob[i] = 65;
}
else if(alice[i] == 49){
bob[i] = 67;
}
else{
bob[i] = 71;
}
}
else if(bob[i-1] == 71){
//G
if(alice[i] == 48){
bob[i] = 84;
}
else if(alice[i] == 49){
bob[i] = 65;
}
else{
bob[i] = 67;
}
}
else{
//C
if(alice[i] == 48){
bob[i] = 71;
}
else if(alice[i] == 49){
bob[i] = 84;
}
else{
bob[i] = 65;
}
}
}
}
for(int x = 0; x<t; x++){
printf("%c",bob[x]);
}
return 0;
}