-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGas.java
More file actions
25 lines (23 loc) · 780 Bytes
/
Copy pathGas.java
File metadata and controls
25 lines (23 loc) · 780 Bytes
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
import java.io.*;
import java.util.concurrent.ThreadLocalRandom;
public class Gas{
public static void main(String[] args) throws FileNotFoundException{
PrintStream output = new PrintStream(new File ("Gasp14400.txt"));
int[] N = {14400};
int time = 0;
for (int y = 0; y<N.length;y++){
int nleft = N[y];
int ntotal = N[y];
for (int j =0; j < N[y];j++){
int rando = ThreadLocalRandom.current().nextInt(1, ntotal + 1);
if (rando < nleft){
nleft--;
} else {
nleft++;
}
time++;
output.printf("%3d %3d, \n", time, nleft);
}
}
}
}