-
Notifications
You must be signed in to change notification settings - Fork 4
/
SevenWonders.java
47 lines (40 loc) · 907 Bytes
/
SevenWonders.java
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
/**
* Created by Tim on 2016-11-08.
*
* Solution to Seven Wonders.
*/
public class SevenWonders {
public static void main(String[] args) {
Kattio io = new Kattio(System.in, System.out);
int T = 0;
int C = 0;
int G = 0;
int smallest;
String sequence = io.getWord();
for(int i = 0 ; i < sequence.length(); i++){
if(sequence.charAt(i) == 'T'){
T++;
}
else if(sequence.charAt(i) == 'C'){
C++;
}
else{
G++;
}
}
if(T <= C && T <= G){
smallest = T;
}
else if(C <= G){
smallest = C;
}
else{
smallest = G;
}
T = T*T;
C = C*C;
G = G*G;
io.println((7*smallest) + T + C + G);
io.close();
}
}