-
Notifications
You must be signed in to change notification settings - Fork 5
/
Borze.java
41 lines (39 loc) · 1.06 KB
/
Borze.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
/*https://codeforces.com/problemset/problem/32/B*/
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class Borze
{
public static void main(String[] args)throws IOException
{
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String input = bufferedReader.readLine();
StringBuffer result = new StringBuffer("");
int start = 0;
while (start < input.length())
{
//System.out.println(start+" "+(start+1)+" "+input.length());
if (input.charAt(start) == '.' && (start+1 >= input.length() || input.charAt(start+1) == '.'))
{
result.append("0");
++start;
}
else if (input.charAt(start) == '.' && input.charAt(start+1) == '-')
{
result.append("0");
++start;
}
else if (input.charAt(start) == '-' && input.charAt(start+1) == '.')
{
result.append("1");
start += 2;
}
else if (input.charAt(start) == '-' && input.charAt(start+1) == '-')
{
result.append("2");
start += 2;
}
}
System.out.println(result.toString());
}
}