-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.java
36 lines (28 loc) · 1.25 KB
/
Task.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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public abstract class Task {
public abstract void solve() throws IOException, InterruptedException;
public abstract void readProblemData() throws IOException;
public abstract void formulateOracleQuestion() throws IOException;
public abstract void decipherOracleAnswer() throws IOException;
public abstract void writeAnswer() throws IOException;
public void askOracle() throws IOException, InterruptedException {
ProcessBuilder builder = new ProcessBuilder();
builder.redirectErrorStream(true);
builder.command("python3", "sat_oracle.py", "sat.cnf", "sat.sol");
Process process = builder.start();
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String buffer;
StringBuilder output = new StringBuilder();
while ((buffer = in.readLine()) != null) {
output.append(buffer).append("\n");
}
int exitCode = process.waitFor();
if (exitCode != 0) {
System.err.println("Error encountered while running oracle");
System.err.println(output.toString());
System.exit(-1);
}
}
}