I hate my life (fixed it) (wrote 1 instead of i) 😭😭😭😭

This commit is contained in:
Matti 2024-05-20 22:11:27 +02:00
parent 9aaeaeed5b
commit 9ff0ded7ea
2 changed files with 3 additions and 20 deletions

View File

@ -3,18 +3,8 @@ package part5.aufg2;
public class Demo {
public static void main(String[] args) {
Queenproblem Q = new Queenproblem();
Q.setField(new int[]{2,4,6,8,1,3,5,0});
Q.print();
System.out.println("============= ALL");
System.out.println(Q.isPossible(7,8));
System.out.println("============= Horiz");
System.out.println(Q.checkHorizontal(7));
System.out.println("============= Vert");
System.out.println(Q.checkVertical(8));
System.out.println("============= Rising");
System.out.println(Q.checkRisingDiagonal(7,8));
System.out.println("============= Falling");
System.out.println(Q.checkFallingDiagonal(7,8));
Q.setField(new int[]{1,0,0,0,0,0,0,0});
Q.solve(0);
}

View File

@ -111,7 +111,7 @@ public class Queenproblem {
}
try {
if (this.field[col-1-i] != 0) {
if (this.field[col-1-i] == row + 1) {
if (this.field[col-1-i] == row+i) {
return false;
}
}
@ -144,14 +144,7 @@ public class Queenproblem {
}
public void solve(int queensPlaced){
field2D = make2D();
if (queensPlaced == 6){
System.out.println("solved 6");
}
for (int col = 1; col < 9; col++) {
if(col == 8) {
System.out.println("solving the last one");
}
if (this.field[col-1] == 0) {
for (int row = 1; row < 9; row++) {
if (isPossible(row,col)) {