-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhorse
More file actions
41 lines (38 loc) · 1.74 KB
/
horse
File metadata and controls
41 lines (38 loc) · 1.74 KB
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
String[] x = {"1", "2", "3", "4", "5", "6", "7", "8"};
String[] y = {"A", "B", "C", "D", "E", "F", "G", "H"};
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
String[] values = input.split("-");
int truemove = 0;
boolean one = false, two = false;
if ((input.length() != 5) || (input.charAt(2) != '-')) {
System.out.println("ERROR input");
} else {
for (int i = 0; i < 8; i++) {
if ((values[0].contains(y[i]) && (values[1].contains(y[i+1]))) || ( !(values[1].contains(y[i]) && (values[0].contains(y[i+1]))))) {
truemove++;
one = true;
}
if ((values[0].contains(y[i]) && values[1].contains(y[i+2])) || (values[1].contains(y[i]) && (values[0].contains(y[i+2])))) {
truemove++;
two = true;
}
}
for (int i = 0; i < 8; i++) {
if (one && ((values[0].contains(x[i]) && values[1].contains(x[i+2])) || (values[1].contains(x[i]) && (values[0].contains(x[i+2]))))) {
truemove++;
}
if (two && ((values[0].contains(x[i]) && values[1].contains(x[i+1])) || (values[1].contains(x[i]) && (values[0].contains(x[i+1]))))) {
truemove++;
}
}
if (truemove == 2) System.out.println("Correct move");
else System.out.println("Incorrect move");
}
}
}