Skip to content

Commit ce0bed5

Browse files
committed
fix manhattan
1 parent 4626b91 commit ce0bed5

File tree

1 file changed

+2
-1
lines changed
  • week4/priority-queues/assignment-8-puzzle

1 file changed

+2
-1
lines changed

week4/priority-queues/assignment-8-puzzle/Board.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public int manhattan() {
5757
for (int i = 0; i < dimension(); ++i)
5858
for (int j = 0; j < dimension(); ++j) {
5959
int v = tiles[i][j];
60-
v = v == 0 ? n * n : v;
60+
if (v == 0) continue;
61+
6162
int x = (v - 1) / n;
6263
int y = (v - 1) % n;
6364

0 commit comments

Comments
 (0)