Compare commits

...

2 Commits

Author SHA1 Message Date
Matti
9ff0ded7ea I hate my life (fixed it) (wrote 1 instead of i) 😭😭😭😭 2024-05-20 22:11:27 +02:00
Matti
9aaeaeed5b 1 Fix in line 113 but still not done???? 2024-05-20 22:05:40 +02:00
2 changed files with 5 additions and 22 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

@ -110,8 +110,8 @@ public class Queenproblem {
;
}
try {
if (this.field[col-1-1] != 0) {
if (this.field[col - 1 - i] == row + 1) {
if (this.field[col-1-i] != 0) {
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)) {