-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuckets.java
More file actions
49 lines (45 loc) · 1.48 KB
/
buckets.java
File metadata and controls
49 lines (45 loc) · 1.48 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
42
43
44
45
46
47
48
49
import java.io.*;
import java.util.*;
class buckets {
public static void main(String[] args) throws IOException{
BufferedReader f = new BufferedReader(new FileReader("buckets.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("buckets.out")));
int[] B = new int[2];
int[] R = new int[2];
int[] L = new int[2];
char[][] farm = new char[10][10];
for (int i = 0; i < 10; i++) {
System.out.print(i);
for(int j = 0; j < 10; j++) {
char dot = (char)f.read();
while(dot != '.' ) {
if (dot == 'B') break;
else if (dot == 'R') break;
else if (dot == 'L') break;
else dot = (char)f.read();
}
System.out.print(dot);
farm[i][j] = dot;
if (dot == 'B') {
//System.out.println("ohboy");
B[0] = i; B[1] = j;
}
else if (dot == 'R') {
R[0] = i; R[1] = j;
}
else if (dot == 'L') {
L[0] = i; L[1] = j;
//System.out.println("ohboy");
}
}
}
int distance = Math.abs((B[1] - L[1])) + Math.abs((B[0] - L[0])) -1;
System.out.println("B: " + B[0] + " " + B[1] + " L: " + L[0] + " " + L[1] + " R: " +R[0] + " " +R[1] + " ");
if ((B[1]== R[1] && B[1]== R[1] || B[0]== R[0] && B[0]== R[0])){
distance++;
//System.out.println("frick");
}
out.println(distance);
out.close(); f.close();
}
}