From 9ff0ded7ea784060bf115e975e4ec4af9730708b Mon Sep 17 00:00:00 2001 From: Matti Date: Mon, 20 May 2024 22:11:27 +0200 Subject: [PATCH] =?UTF-8?q?I=20hate=20my=20life=20(fixed=20it)=20(wrote=20?= =?UTF-8?q?1=20instead=20of=20i)=20=F0=9F=98=AD=F0=9F=98=AD=F0=9F=98=AD?= =?UTF-8?q?=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/part5/aufg2/Demo.java | 14 ++------------ src/part5/aufg2/Queenproblem.java | 9 +-------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/part5/aufg2/Demo.java b/src/part5/aufg2/Demo.java index fa9823c..6b439f4 100644 --- a/src/part5/aufg2/Demo.java +++ b/src/part5/aufg2/Demo.java @@ -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); } diff --git a/src/part5/aufg2/Queenproblem.java b/src/part5/aufg2/Queenproblem.java index c747b16..7f5f657 100644 --- a/src/part5/aufg2/Queenproblem.java +++ b/src/part5/aufg2/Queenproblem.java @@ -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)) {