Commit 1ab393bf authored by ucifm's avatar ucifm Committed by uxrog
Browse files

added some more execution tests

parent 970a85d9
Pipeline #180544 failed with stage
in 14 minutes and 28 seconds
class Main {
public int x;
public int y;
public static void main(String[] args) {
Main m = new Main();
m = m.init()
.addToX(10)
.addToY(10)
.print()
.addToX(3)
.addToX(5)
.print()
.bar()
.bar()
.bar()
.bar()
.bar()
.bar()
.addToY(-4)
.print()
.newMain()
.addToY(4)
.addToY(4)
.addToY(4)
.addToY(4 + m.y)
.addToX(4)
.addToY(14)
.addToY(-5)
.print()
.init()
.print();
int sum = m.x + m.y;
System.out.println(sum);
}
public Main init() {
this.x = 1;
this.y = 1;
return this;
}
public Main bar() {
return this;
}
public Main addToX(int i) {
this.x = x + i;
return this;
}
public Main addToY(int i) {
this.y = y + i;
return this;
}
public Main print() {
System.out.println(this.x);
System.out.println(this.y);
return this;
}
public Main newMain() {
return new Main();
}
}
11
11
19
11
19
7
4
32
1
1
2
class Main {
public static void main(String[] args) {
GameOfLife gof = new GameOfLife();
gof.init(10, 10);
gof.set(4, 4, true);
gof.set(4, 5, true);
gof.set(4, 6, true);
gof.set(5, 4, true);
gof.set(5, 5, true);
gof.set(5, 6, true);
gof.set(6, 4, true);
gof.set(6, 5, true);
gof.set(6, 6, true);
gof.printBoard();
int i = 0;
while (i < 10) {
gof.update();
gof.printBoard();
i = i + 1;
}
}
}
class GameOfLife {
public boolean[][] currentTiles;
public boolean[][] backupTiles;
public int width;
public int height;
public void init(int width, int height) {
this.width = width;
this.height = height;
currentTiles = new boolean[width][];
backupTiles = new boolean[width][];
int i = 0;
while (i < width) {
currentTiles[i] = new boolean[height];
backupTiles[i] = new boolean[height];
i = i + 1;
}
}
public boolean get(int x, int y) {
if (x < 0 || y < 0 || x >= width || y >= height) {
return false;
}
return this.currentTiles[x][y];
}
public void set(int x, int y, boolean b) {
this.currentTiles[x][y] = b;
}
public void setNew(int x, int y, boolean b) {
this.backupTiles[x][y] = b;
}
public int countNeighbors(int x, int y) {
int count = 0;
int dy = -1;
while (dy <= 1) {
int dx = -1;
while (dx <= 1) {
if ((dy != 0 || dx != 0) && get(x + dx, y + dy))
count = count + 1;
dx = dx + 1;
}
dy = dy + 1;
}
return count;
}
public void update() {
int y = 0;
while (y < height) {
int x = 0;
while (x < width) {
int neighbors = countNeighbors(x, y);
if (get(x, y)) {
if (neighbors < 2) {
setNew(x, y, false);
} else if (neighbors <= 3) {
setNew(x, y, true);
} else {
setNew(x, y, false);
}
} else {
setNew(x, y, neighbors == 3);
}
x = x + 1;
}
y = y + 1;
}
boolean[][] tmp = currentTiles;
currentTiles = backupTiles;
backupTiles = tmp;
}
public void printBoard() {
int y = height - 1;
while (y >= 0) {
int x = 0;
while (x < width) {
if (get(x, y)) {
System.out.write(35);
} else {
System.out.write(46);
}
x = x + 1;
}
System.out.write(10);
y = y - 1;
}
System.out.flush();
}
}
..........
..........
..........
....###...
....###...
....###...
..........
..........
..........
..........
..........
..........
.....#....
....#.#...
...#...#..
....#.#...
.....#....
..........
..........
..........
..........
..........
.....#....
....###...
...##.##..
....###...
.....#....
..........
..........
..........
..........
..........
....###...
...#...#..
...#...#..
...#...#..
....###...
..........
..........
..........
..........
.....#....
....###...
...#.#.#..
..###.###.
...#.#.#..
....###...
.....#....
..........
..........
..........
....###...
..........
..#.....#.
..#.....#.
..#.....#.
..........
....###...
..........
..........
.....#....
.....#....
.....#....
..........
.###...###
..........
.....#....
.....#....
.....#....
..........
..........
....###...
..........
..#.....#.
..#.....#.
..#.....#.
..........
....###...
..........
..........
.....#....
.....#....
.....#....
..........
.###...###
..........
.....#....
.....#....
.....#....
..........
..........
....###...
..........
..#.....#.
..#.....#.
..#.....#.
..........
....###...
..........
..........
.....#....
.....#....
.....#....
..........
.###...###
..........
.....#....
.....#....
.....#....
..........
class Main {
public static void main(String[] args) {
Main m = new Main();
System.out.println(m.bar());
System.out.println(m.baz(1));
System.out.println(m.baz(42));
System.out.println(m.foo(0));
System.out.println(m.foo(1));
System.out.println(m.foo(2));
System.out.println(m.foo(3));
System.out.println(m.foo2(1));
System.out.println(m.foo2(0));
System.out.println(m.foo3(1));
System.out.println(m.foo3(0));
System.out.println(m.foo4(0, 0, 0));
System.out.println(m.foo4(0, 0, 1));
System.out.println(m.foo4(0, 1, 0));
System.out.println(m.foo4(0, 1, 1));
System.out.println(m.foo4(1, 0, 0));
System.out.println(m.foo4(1, 0, 1));
System.out.println(m.foo4(1, 1, 0));
System.out.println(m.foo4(1, 1, 1));
System.out.println(m.foo5(0, 0, 0));
System.out.println(m.foo5(0, 0, 1));
System.out.println(m.foo5(0, 1, 0));
System.out.println(m.foo5(0, 1, 1));
System.out.println(m.foo5(1, 0, 0));
System.out.println(m.foo5(1, 0, 1));
System.out.println(m.foo5(1, 1, 0));
System.out.println(m.foo5(1, 1, 1));
System.out.println(m.foo6(0));
System.out.println(m.foo6(50));
System.out.println(m.foo7(0));
System.out.println(m.foo7(50));
}
public int bar() {
int i = 0;
while (i < 100) {
if (i == 10) {
return i;
}
i = i + 1;
}
return -1;
}
public int baz(int j) {
int i = 42;
if (i == j) {
return 0;
} else {
return 1;
}
}
public int foo(int i) {
if (i == 0) {
} else {
if (i == 1) {
} else {
if (i == 2) {
} else {
return 3;
}
}
return 4;
}
return 5;
}
public int foo2(int j) {
if (j == 0) {
while (j == 3) {
if (j == 5) {
} else {
return 6;
}
}
}
return 7;
}
public int foo3(int j) {
if (j == 0) {
while (j == 3) {
if (j == 5) {
return 6;
} else {
}
}
}
return 7;
}
public int foo4(int i, int j, int k) {
if (i == 0) {
if (j == 0) {
if (k == 0) {
System.out.println(1);
} else {
System.out.println(2);
}
} else {
if (k == 0) {
System.out.println(3);
} else {
System.out.println(4);
}
}
} else {
if (j == 0) {
if (k == 0) {
System.out.println(5);
} else {
System.out.println(6);
}
} else {
if (k == 0) {
System.out.println(7);
} else {
System.out.println(8);
}
}
}
return 1;
}
public int foo5(int i, int j, int k) {
if (i == 0) {
if (j == 0) {
if (k == 0) {
} else {
}
} else {
if (k == 0) {
} else {
return 2;
}
}
return 6;
} else {
if (j == 0) {
if (k == 0) {
return 3;
} else {
}
} else {
if (k == 0) {
} else {
}
}
}
return 1;
}
public int foo6(int i) {
while (i > 10) {
if (i == 100) {
return i;
} else {
}
i = i + 1;
}
return 2;
}
public int foo7(int i) {
while (i > 10) {
if (i == 100) {
} else {
return i;
}
}
return 2;
}
}
10
1
0
5
4
4
3
7
7
7
7
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
6
6
6
2
3
1
1
1
2
100
2
50
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment