-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvajningsplikt.java
97 lines (89 loc) · 2.39 KB
/
vajningsplikt.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
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
91
92
93
94
95
96
97
import java.io.*;
import java.util.*;
public class vajningsplikt {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
StringTokenizer st = new StringTokenizer(in.readLine());
String a = st.nextToken();
String b = st.nextToken();
String c = st.nextToken();
String straight = getStraight(a);
String right = getRight(a);
String left = getLeft(a);
if(left.equals(b)) {
if(right.equals(c) || straight.equals(c)) {
out.println("Yes");
}
else {
out.println("No");
}
}
else if (straight.equals(b)) {
if(right.equals(c)) {
out.println("Yes");
}
else {
out.println("No");
}
}
else {
out.println("No");
}
out.close();
}
public static String getLeft(String dir) {
String res = "";
switch (dir) {
case "North":
res = "East";
break;
case "East":
res = "South";
break;
case "South":
res = "West";
break;
case "West":
res = "North";
break;
}
return res;
}
public static String getRight(String dir) {
String res = "";
switch (dir) {
case "North":
res = "West";
break;
case "East":
res = "North";
break;
case "South":
res = "East";
break;
case "West":
res = "South";
break;
}
return res;
}
public static String getStraight(String dir) {
String res = "";
switch (dir) {
case "North":
res = "South";
break;
case "East":
res = "West";
break;
case "South":
res = "North";
break;
case "West":
res = "East";
break;
}
return res;
}
}